How to obtain peaks in the y-axis above a reference line in matlab plot

2 次查看(过去 30 天)
I want to get all the pnts in yaxes for a matlab plot above reference line -70 db

回答(2 个)

KSSV
KSSV 2018-6-13
Let x,y be your data. And reference line is at y = y0. To extract data above y = y0:
idx = y>=y0 ;
x1 = x(idx) ;
y1 = y(idx) ;
  1 个评论
TRISHITA BANERJEE
TRISHITA BANERJEE 2018-6-13
This is my script..i want to see peaks of yaxes where it is over the reference line -75.21 db
function [h1, h2, h1_nl, h2_nl] = farina_deconvolution(y1,y2,xinv,CorrFac,ctrl_plot_var ) %% Farina Deconvolution % Convolves the measured signals y1 and y2 with xinv and separates % their linear and non-linear impulse responses
L1 = length(xinv);
L2 = length(y1);
Lin = L1+L2-1;
XINV1 = fft(xinv,Lin);
Y1 = fft(y1,Lin);
h1_complete = ifft(XINV1.*Y1);
L1 = length(xinv);
L2 = length(y2);
Lin = L1+L2-1;
XINV2 = fft(xinv,Lin);
Y2 = fft(y2,Lin);
h2_complete = ifft(XINV2.*Y2);
% extract linear impulse response part
h1 = h1_complete (length(xinv):end)/CorrFac;
h2 = h2_complete (length(xinv):end)/CorrFac;
% extract non-linear impulse response part
h1_nl = h1_complete (1:length(xinv)-1)/CorrFac;
h2_nl = h2_complete (1:length(xinv)-1)/CorrFac;
if ctrl_plot_var
figure
subplot(2,1,1);
plot(20*log10(abs(h1_complete)))
hline = refline([0 -70]); % highlight reference thersold at -80 DB
hline.Color = 'r';
title('Complete Impulse Responses')
grid on
ylabel('h1 \rightarrow dB')
subplot(2,1,2);
plot(20*log10(abs(h2_complete)))
hline = refline([0 -75.21]); % highlight reference thersold at -80 DB
hline.Color = 'r';
ylabel('h2 \rightarrow dB')
grid on
figure
subplot(2,1,1);
plot(20*log10(abs(h1)))
hline = refline([0 -75.21]); % highlight reference thersold at -80 DB
hline.Color = 'r';
title('Linear Impulse Responses')
grid on
ylabel('h1 \rightarrow dB')
subplot(2,1,2);
plot(20*log10(abs(h2)))
hline = refline([0 -75.21]); % highlight reference thersold at -80 DB
hline.Color = 'r';
ylabel('h2 \rightarrow dB')
grid on
figure
subplot(2,1,1);
plot(h1)
title('Linear Impulse Responses')
grid on
ylabel('h1 \rightarrow dB')
subplot(2,1,2);
plot(h2)
ylabel('h2 \rightarrow dB')
grid on
end
end

请先登录,再进行评论。


Star Strider
Star Strider 2018-6-13
If you have the Signal Processing Toolbox, use the findpeaks (link) function, and the 'MinPeakHeight' (and perhaps also the 'MinPeakDistance') values set to the appropriate thresholds. For 'MinPeakHeight that would be either -70 if your original data are in dB, or 3.162277660168379e-04 otherwise. You will have to experiment to get the correct 'MinPeakDistance' value.
If you do not, and you have R2017b or later, use the islocalmax (link) function. You will first have to threshold your data to present data only greater than -70 dB. Again, you will have to experiment to get the results you want.

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by