How to find the maximum value of C that corresponds to a set of X,Y coordinates?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Brianna Miranda
le 29 Juil 2022
Commenté : Star Strider
le 29 Juil 2022
I have a spectrogram plot that contains X,Y and C. I want to find the maximum values of C from that spectrogram and also the XY coordinates that they correspond to. I have this so far but I am not sure how to get the X,Y coordinates that each value of max C corresponds to.
imagesc(X,Y,10*log10(C))
maxC = max(C);
0 commentaires
Réponse acceptée
Star Strider
le 29 Juil 2022
The spectrogram plot is actually a surf plot with the view set to display it looking from the top, so the ‘Z’ values will give you all the information you want.
One way of getting that information from the spectrogram is to use the medfreq funciton. See Track Chirps in Audio Signal for an example.
2 commentaires
Star Strider
le 29 Juil 2022
With a spectrogram, the ‘maximum’ can be defined as the maximum value of the ‘Z’ matrix (the eqay solution), or the maximum frequency with respect to time (the solution that the link I posted could be useful to find).
The maximum value of the ‘Z’ matrix is simply:
[r,c] = find(Z == max(Z(:))
so for example —
[X,Y] = ndgrid(1:0.1:5);
Z = randn(size(X))
[r,c] = find(Z == max(Z(:)))
maxZ = Z(r,c)
figure
surf(X,Y,Z)
hold on
stem3(X(r,c),Y(r,c),Z(r,c), '^r', 'MarkerFaceColor','r')
hold off
grid on
.
Plus de réponses (1)
Voss
le 29 Juil 2022
X = 1:3:31;
Y = 1:2:13;
C = rand(numel(Y),numel(X));
imagesc(X,Y,10*log10(C))
[maxC,idx] = max(C(:))
[yidx,xidx] = ind2sub(size(C),idx)
maxX = X(xidx)
maxY = Y(yidx)
line(maxX,maxY,'Marker','x','MarkerEdgeColor','r')
0 commentaires
Voir également
Catégories
En savoir plus sur Time-Frequency Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!