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

2 Ansichten (letzte 30 Tage)
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!

Antworten (1)

Prateekshya
Prateekshya am 7 Nov. 2023
Bearbeitet: Prateekshya am 7 Nov. 2023
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 Kommentar
Aristarchos Mavridis
Aristarchos Mavridis am 9 Nov. 2023
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by