フィルターのクリア

Get peak values from a Surface mesh figure?

18 ビュー (過去 30 日間)
Juan Vences
Juan Vences 2021 年 8 月 4 日
編集済み: Juan Vences 2021 年 8 月 5 日
Hello dear Matlab users !
Question for those who have lots of Matlab skills (i don't '^_^ ) and love to give some help
Let's say there is a figure (surface mesh) which plots a surface from 3 equal size matrices ("m" by "n"). And from that figure, peak values are of interest. Could somebody share an idea of how to get those peak values (x,y,z) without looking/searching for them manually please? (could be using the "Brush" [preferably], or a "fancy function"?... I have no Image Processing Toolbox too... i think lol)
Please look at attached image for example
Many thanks!
  6 件のコメント
Scott MacKenzie
Scott MacKenzie 2021 年 8 月 4 日
OK, I'll post a solution in a moment that does not use findpeaks.
Juan Vences
Juan Vences 2021 年 8 月 4 日
Appreciate your help!

サインインしてコメントする。

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 8 月 4 日
編集済み: Scott MacKenzie 2021 年 8 月 5 日
Here's a solution that does not use findpeaks (since you do not have the Signal Processing Toolbox). Below, I am using MATLAB's build-in peaks function and a threshold of 6. In the surface plot you posted, the peaks circled are above about 156.5, so you'll need to adjust the variable threshold accordingly.
% test data
[X,Y,Z] = peaks(25);
mesh(X,Y,Z); % can also use surf
xlabel('x');
ylabel('y');
hold on;
threshold = 6; % find peaks with Z above this value (adjust, as needed)
peakLogical = Z > threshold;
xx = X(peakLogical);
yy = Y(peakLogical);
zz = Z(peakLogical);
vOffset = 0.5; % shift up a bit so points are clearly visible
zz = zz + vOffset;
% show peaks in surface plot
scatter3(xx, yy, zz, 'r', 'filled');
  5 件のコメント
Scott MacKenzie
Scott MacKenzie 2021 年 8 月 5 日
編集済み: Scott MacKenzie 2021 年 8 月 5 日
@Juan Vences. You're welcome.
BTW, I just simplified the answer. See the new calculations for xx, yy, and zz. Works the same, but much simpler.
Juan Vences
Juan Vences 2021 年 8 月 5 日
編集済み: Juan Vences 2021 年 8 月 5 日
@Scott MacKenzie Thanks so much for all of your time and great help
Super thumbs up!
(in my case I removed "[X,Y,Z] = peaks(25);" in my script (yours actually). For the rest of the script, I used my 'data matrices' and it worked, though I'm not too sure how by removing that 'part/line' it affects the results...lol. On the plot generated with my data, I can see the dots on the peaks (depending on the thresold defined of course), and coordinates match and make sense, so I guess it works!)

サインインしてコメントする。

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 8 月 4 日
You can use MATLAB's built in findpeaks() fcn to clocate local maxima of your data - see the doc: https://www.mathworks.com/help/signal/ref/findpeaks.html
  1 件のコメント
Juan Vences
Juan Vences 2021 年 8 月 4 日
I'm exploring that option

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by