How can I plot the maximum values of the double matrix ?

4 vues (au cours des 30 derniers jours)
Vahram Voskerchyan
Vahram Voskerchyan le 9 Juin 2021
I have a double matrix (200 x 200 double). When I plot it it looks like this.
I want to get the maximum values of this plot like shown in the example.
I have tried to loop inside the elements with the length of the matrix and use findpeaks and assign the maximums to the indexes.
for i = 1:length(E2_gc_comparisn)
[pks,locs,fwhm,proms] = findpeaks(E2_gc_comparison(:,i),XX);
[~,j] = max(pks);
angle(i) = locs(j);
end
%Where E2_gc_comparison is my matrix
%Another way to do it to use
[M,I] = max(E2_gc_comparison)
But when I try to plot it I get:
%Another way that I tried
Val = unique(E2_gc_comparison)
And also got the same graph. How can I plot the matrix so I have something like this.

Réponse acceptée

Joel Lynch
Joel Lynch le 9 Juin 2021
Max() has an optional third argument that determines the index along which to take the maximum. So for a 10x20 matrix A,
A_max(1,1:20) = max( A, [], 1 ) % Take maximum of all rows, at each column of A
and
A_max(1:10,1) = max( A, [], 2 ) % Take maximum of all columns, at each row of A
So for your problem, you should try this:
[M,I] = max(E2_gc_comparison,[],idx) % where idx = 1 or 2, depending on size of E2_gc_comp
  5 commentaires
Joel Lynch
Joel Lynch le 9 Juin 2021
When I load the MAT file and run
plot(max(E2_gc_comparisn,[],2))
I get the following plot:
Is this not correct?
Vahram Voskerchyan
Vahram Voskerchyan le 9 Juin 2021
Oh yeah it is! Thanks a lot, I was doing something wrong.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by