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

조회 수: 2 (최근 30일)
TRISHITA BANERJEE
TRISHITA BANERJEE 2018년 6월 13일
답변: Star Strider 2018년 6월 13일
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