필터 지우기
필터 지우기

Automatically selecting peaks from a surf plot an creating new variables for them

조회 수: 4 (최근 30일)
Hello
I have a 100x100 numeric variable, which looks like this when plotted on a surf plot:
What I'm looking for, is a way to automatically create some new variables, each containing only one of the peaks, with the rest of the values deleted, as shown below :
Ideally I would like this to work for any number of peaks (generating one new variable for each of them),
and if possible, ignoring peaks below a certain threshold would be nice.
Thank you for your time!

답변 (1개)

Prateekshya
Prateekshya 2023년 11월 7일
편집: Prateekshya 2023년 11월 7일
Hi Aristarchos,
As per my understanding, you want to extract the peak values from a 3D surface plot.
The closest workaround is to find the maximum values in the data from which the figure is generated. You can use the following functions.
[maxValue, maxIndex] = max(Z(:)); % Gives the maximum value and the corresponding index
[row, col] = ind2sub(size(Z), maxIndex); % Gives the row and column for the position
[row, col] = find(Z > threshold); % Gives the rows and columns for the corresponding positions
peakValues = Z(sub2ind(size(Z), row, col)); % Gives the exact values
binaryImage = imregionalmax(Z); % Gives a matrix indicating 1 at the positions of maximum values
[row, col] = find(binaryImage); % Gives the set of rows and columns for the corresponding positions
peakValues = Z(sub2ind(size(Z), row, col)); % Gives the exact values
"Z" is the matrix containing the surface data.
If you only have the figure and not the data, you can follow this to extract the data from the figure: https://in.mathworks.com/matlabcentral/answers/100687-how-do-i-extract-data-from-matlab-figures
I hope it helps!
  댓글 수: 1
Aristarchos Mavridis
Aristarchos Mavridis 2023년 11월 9일
Hello Prateekshya,
Thank you for taking the time to answer.
I'm familiar with finding local maxima, my problem is more about selecting the whole "mountain" around them automatically. I know there are some gradient ascent methods I could use, but I was wondering whether matlab has a built-in tool that could do the job.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by