Plotting only highest peaks from multiple signals

조회 수: 11 (최근 30일)
Lisa Justin
Lisa Justin 2019년 12월 3일
댓글: Lisa Justin 2019년 12월 9일
Hi,
I need to extract only the peaks of three signals so I have one plot without changing the amplitude of the individual plots.
fs = 2e3;
t = (0:1/fs:1-1/fs)';
A= sin(2*pi*19*t);
B= chirp(t-0.6,61,t(end),603,'quadratic');
C=cos(2*pi*19*t);
peakSig= A+B+C;

채택된 답변

Image Analyst
Image Analyst 2019년 12월 3일
Lisa, try using max() function to compute the max.
fs = 2e3;
t = (0:1/fs:1-1/fs)';
A= sin(2*pi*19*t);
B= chirp(t-0.6,61,t(end),603,'quadratic');
C=cos(2*pi*19*t);
plot(t, A, 'r-', 'LineWidth', 2);
hold on;
plot(t, B, 'g-', 'LineWidth', 2);
plot(t, C, 'b-', 'LineWidth', 2);
% Get the highest of any signal:
peakSig = max([A, B, C], [], 2);
% Get the lowest of any signal:
valleySig = min([A, B, C], [], 2);
plot(t, peakSig, 'k-', 'LineWidth', 3);
plot(t, valleySig, 'k-', 'LineWidth', 3);
grid on;
% Zoom in so we can actually see what's happening:
xlim([0, 0.04]);
legend('A', 'B', 'C', 'peakSig', 'valleySig');
0001 Screenshot.png
If you have the valley signal in there also, you'll get this:
0000 Screenshot.png
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 12월 3일
Great Sir!
Lisa Justin
Lisa Justin 2019년 12월 9일
Thanks Image Analyst. Just what I wanted.
Great.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 12월 3일
fs = 2e3;
t = (0:1/fs:1-1/fs)';
A= sin(2*pi*19*t);
B= chirp(t-0.6,61,t(end),603,'quadratic');
C=cos(2*pi*19*t);
peakSig= max(A)+max(B)+max(C) % You can find the maximum of A/B/C using max function
Or:
You can use findpeaks function to get the peaks of the individual signal.

ABHILASH SINGH
ABHILASH SINGH 2019년 12월 3일
편집: ABHILASH SINGH 2019년 12월 3일
I think you are looking for this.
fs = 2e3;
t = (0:1/fs:1-1/fs)';
A= sin(2*pi*19*t);
B= chirp(t-0.6,61,t(end),603,'quadratic');
C=cos(2*pi*19*t);
peakSig= A+B+C;
plot(t,A,t,B,t,C)
figure
plot(t,envelope(peakSig))
Let me know if you need something different. This is the peakSig vs t
This is the peak of the three signals together

카테고리

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