How to find the maximum value of C that corresponds to a set of X,Y coordinates?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brianna Miranda
el 29 de Jul. de 2022
Comentada: Star Strider
el 29 de Jul. de 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 comentarios
Respuesta aceptada
Star Strider
el 29 de Jul. de 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 comentarios
Star Strider
el 29 de Jul. de 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
.
Más respuestas (1)
Voss
el 29 de Jul. de 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 comentarios
Ver también
Categorías
Más información sobre Time-Frequency Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!