MATLAB Answers


plot simulink in matlab

Asked by papan dey on 5 Feb 2013
i have generated simulink figure and can convert it in matlab using plot(signal) . now if i want to take the graph between a time limit such as 0.2s t0 0.5s, which command should i write?


Log in to comment.



2 Answers

Answer by Andreas Goser
on 5 Feb 2013

There is actually no other command needed than PLOT. You only have to plot different DATA. Example:

t=0:0.001:1; % ms
data=sin(10*t); % example data
plot(t,data) % full plot
plot(t(11:51),data(11:51)) % from 0.01 s to 0.05 s


Log in to comment.

Answer by cr
on 7 Feb 2013
Edited by cr
on 7 Feb 2013

Well, may be you can do it. Say, tout is the vector of all time values and yout is vector of all signal values.

newtimevec = find(tout>=0.2,1):find(tout<=0.5,1,'last');
plot(tout(newtimevec), yout(newtimevec));

This should give you the plot you asked for.


Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!