How to find the maximum value of C that corresponds to a set of X,Y coordinates?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2022-7-29
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 个评论
Star Strider
2022-7-29
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
.
更多回答(1 个)
Voss
2022-7-29
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time-Frequency Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!