Find a row of the maximum of a matrix
1 view (last 30 days)
Show older comments
Miguel Albuquerque on 4 Jul 2022
Answered: Image Analyst on 4 Jul 2022
Hey guys, thanks in advance,
I have this code that correlates in time two signals. These correlation is made in a matrix 3199 x 400. The 3199 values are the values of the signals in frequency, and 400 values are positions of a plane, and the values of the signal are different for each column.
I have an example for a position of a plane(400,184), where I have this correlation :
As seen in the following figure, and the maximum of that correlation indicated by the data tip.
In the previous figure, x is a time vector(time_compression) and y is the value of the signal in time(range_compressed).
Basically , I have this matrix(matlab.mat) and I want to find in the entire matrix, the max value of correlation, that in this example is 2.82e-7, and for that value, find the row(time_compression_cut) where this value is, and multiply it by speed of light.
I have this code, but im having troubles finding where this maximum value is for the rows, and then multiply the value of the row by speed of light.
range_compressed_matrix is the entire matrix filled by zeros, with execption of column 184. Waypoints are the positions of the plane, meaning each column of the matrix. time_compression_cut is the values of the rows of range_compressed_matrix.
[x,y] = max(max(max(range_compressed_matrix))); % max value of matrix
x_max = waypoints(y);
y_max = time_compression_cut(x);
Image Analyst on 4 Jul 2022
To find the max of the matrix:
maxValue = max(range_compressed_matrix(:))
% To find what row(s) and column(s) this occurs at use find():
[rows, columns] = find(range_compressed_matrix == maxValue)
More Answers (1)
dpb on 4 Jul 2022
I fail to see the point in an array of 1960x400 of which 1959 columns are all identically zero???
That aside, what's the issue in finding the row associated with the maximum, whether the whole array as
or just the non-zero column --
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!