How to find peak coordinates of a signal within a specific range?
이전 댓글 표시
The code below is of two signals. I am trying to take the peak/max value of "signal_1", then create a range: (max_value_x_component - 0.1e+9) to (max_value_x_component + 0.1e+9).
Then for signal_5 I want to find the x and y coordinates of the peak/max value between the rang: (max_value_x_component - 0.1e+9) to (max_value_x_component + 0.1e+9).
I am looking to run this in a loop, so I need to actually find the peak values within the range through coding and not just by looking at a graph.
The code below will produce two figures with two graphs on each figure as seen in image 1 below. The graph that I am interested in analyzing is the second two graphs labeled "Graph of signal Fourier Transform". When looking at the graph you only see two large peaks/spikes one on the left near the origin and one on the far right. You need zoom into the left peak to see the waveform being analyzed as seen in image 2 below.
h = 1.00E-12;
t = 0:h:40E-9;
A = 1;
A2 = 1.1111111;
A3 = 2.2222222;
A4 = 10;
A5 = 20;
f=3E9;
nfft = 2^(nextpow2(length(t))+5);
%Graphed signal_1
signal = cos(2*pi*f*t).*(A.*(heaviside(t)-heaviside(t-39E-9)));
snrdB = 0;
noise = 10^(-snrdB/20)*randn(size(signal));
sn = noise+signal;
y1 = fft(sn,nfft);
m1 = abs(y1);
er1 = (0:length(y1)-1)*(1/h)/length(y1);
figure (1)
subplot(2,1,1)
plot(t,sn)
title('Graph of signal_1')
xlabel('Time') % x-axis label
ylabel('Amplitude') % y-axis label
subplot(2,1,2)
plot(er1,m1)
grid on
title('Graph of signal_1 Fourier Transform')
xlabel('Frequency') % x-axis label
ylabel('Amplitude') % y-axis label
%Graphed signal_5
signal_5 = [cos(2*pi*f*t).*(A5.*(heaviside(t)-heaviside(t-1E-9)))]+[cos(2*pi*f*t).*(A5.*(heaviside(t-4E-9)-heaviside(t-5E-9)))];
snrdB = 0;
noise = 10^(-snrdB/20)*randn(size(signal_5));
s5n = noise+signal_5;
y5 = fft(s5n,nfft);
m5 = abs(y5);
er5 = (0:length(y5)-1)*(1/h)/length(y5);
indexmax = find(max(m5) == m5)
xmax = er5(indexmax)
ymax = m5(indexmax)
figure (5)
subplot(2,1,1)
plot(t,s5n)
title('Graph of signal_5')
xlabel('Time') % x-axis label
ylabel('Amplitude') % y-axis label
subplot(2,1,2)
plot(er5,m5)
grid on
title('Graph of signal_5 Fourier Transform')
xlabel('Frequency') % x-axis label
ylabel('Amplitude') % y-axis label

Image 1. This is the figure that will be produced.

Image 2. This is the zoomed in waveform for the Four Transform graph of signal 3.
댓글 수: 4
Omanshu Thapliyal
2017년 3월 30일
Could you elaborate what you are trying to do and what you mean by 'max_value_x_component'? Because your signal1 plot shows an x-axis range of the order of -8.
Image Analyst
2017년 3월 30일
Same question. it's not clear. Perhaps findpeaks() will help you.
Anonymous45
2017년 4월 3일
Anonymous45
2017년 4월 3일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!