How can I put the values of the y-axis in a vector and find the maximum?
2 次查看(过去 30 天)
显示 更早的评论
This is my MATLAB code:
data=csvread("abc.CSV");
[H, f]=make_fft(data(:,2),data(:,1)); %my function
figure
stem(f,H)
set(gca,'xscale','log')
How can I see values of the plot in a vector? I should find the first and second maximum along the y axis
2 个评论
Enrico Gambini
2022-2-16
Hello.
I did not fully understand your question. The values of the y-axis are stored inside vector "H", you mean that you want to see a better scale in the y-axis?
采纳的回答
Enrico Gambini
2022-2-16
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"
2 个评论
Enrico Gambini
2022-2-17
If you want to find the x-axis value of the second maximum y value you can Just:
x_2ndmax=f(idx)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!