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 で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!