displacing iterations of a signal

조회 수: 1 (최근 30일)
Alexis Thompson
Alexis Thompson 2020년 7월 2일
편집: Star Strider 2020년 7월 3일
What do I add to the code after plot(stim) so that each iteration is displaced from one anohter on the x axis? Each iteration of the signal is represented with a different color on the plot.

답변 (2개)

Star Strider
Star Strider 2020년 7월 3일
편집: Star Strider 2020년 7월 3일
I am not certain what you want to do. If you want the different waveforms to appear consecutively, plot them against an independent variable vector and then offset that vector.
Try simething like this:
t = linspace(0, 100, 101);
y1 = sin(2*pi*t*5/max(t));
y2 = cos(2*pi*t*10/max(t));
figure
subplot(3,1,1)
plot(y1) % Plot Together Without Indepdent Variable
hold on
plot(y2)
hold off
title('Plot Together Without Indepdent Variable')
subplot(3,1,2)
plot(t, y1) % Plot Together With Indepdent Variable
hold on
plot(t,y2)
hold off
title('Plot Together With Indepdent Variable')
subplot(3,1,3)
plot(t, y1) % Plot Consecutively With Indepdent Variable
hold on
plot(t+t(end), y2)
hold off
title('Plot Consecutively With Indepdent Variable')
EDIT — (3 Jul 2020 at 19:57)
Added plot image —
.

Image Analyst
Image Analyst 2020년 7월 3일
In your loop, you can just create an x that gets shifted on each iteration
stim = ......
x = 5000 * i + (1 : length(stim)); % Shifts over by 5000 for each i
plot(x, stim)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by