MATLAB Answers

Mustafa Ertay

Matlab simulink toworkspace block plot problem?

Asked by Mustafa Ertay
on 26 May 2013

I have problem with the plot. I want to plot the graphics from simulink with the to workspace block. It is plotting but the time axis is starting from wrong value. For example my time is 3 , it must be plotted from zero to 3 but it is plotting 2.7 to 3. This is wrong. How can I fix this? Can you help me?



1 Answer

Answer by Azzi Abdelmalek
on 26 May 2013

Use a Clock block connected to to workspace block to get the simulation time t, then

plot(t,y) % should start at 0


The vector lenghts of the variables are different so I constraint the workspace tout variable to other variables' lenght to plot. It becmoes same length but When I plot them it is plotting but the time axis started from 2.7.

The time vector and your signal should have the same length, instead of to workspace block, use a scope, then set the properties of your scope like below:

  1. in History uncheck Limit data points to last and check save data to workspace , and set variable name to data
  2. simulate your system then, in workspace type

it works. Thank you :)

Join the 15-year community celebration.

Play games and win prizes!

Learn more
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!