MATLAB Answers

displacing iterations of a signal

4 views (last 30 days)
Alexis Thompson
Alexis Thompson on 2 Jul 2020
Edited: Star Strider on 3 Jul 2020
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.

  1 Comment

dpb
dpb on 2 Jul 2020
Consider waterfall

Sign in to comment.

Answers (2)

Star Strider
Star Strider on 3 Jul 2020
Edited: Star Strider on 3 Jul 2020
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 —
.

  0 Comments

Sign in to comment.


Image Analyst
Image Analyst on 3 Jul 2020
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)

  0 Comments

Sign in to comment.

Categories

Tags


Translated by