How can I put the values of the y-axis in a vector and find the maximum?

4 views (last 30 days)
This is my MATLAB code:
[H, f]=make_fft(data(:,2),data(:,1)); %my function
How can I see values of the plot in a vector? I should find the first and second maximum along the y axis
Lorenza Curcio
Lorenza Curcio on 16 Feb 2022
if I look for the maximum of H I get the maximum value, but what if I want the second largest value?

Sign in to comment.

Accepted Answer

Enrico Gambini
Enrico Gambini on 16 Feb 2022
You mean this?
H_sorted=sort(H); %sort vector "H" in ascending order
idx=find(H==H_sorted(end-1)); %find the index of the second maximum value in vector "H"
2nd_max_value=H(idx); %this is the second maximum value of vector "H"
Enrico Gambini
Enrico Gambini on 17 Feb 2022
If you want to find the x-axis value of the second maximum y value you can Just:

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!