# why plot of ''To Workspace'' of matlab does not fit the scope of simulink?

I am simulating a complete system for control loop. since I need the data to be saved on matlab, I wrote a small code that saves the data in matlab and I could plot. my system has a sample time of 156Hz, so on the scope I can see this sampling as you see on the pic Now after writing the code in matlab to save the same plot is:

x_sim= (dummy.time);
x_sim1 = x_sim(1:end);
y_sim = (dummy.signals);
y_sim1 =y_sim.values(1:end);
plot(x_sim1,y_sim1)
xlabel('time in seconds');
ylabel('voltage');


here is the plot of the output: I used structure with time to save the data of the signal. here is the simulink scope and workplace

You are plotting discrete time points using the plot function which will simply join the dots. The data points don't give any indication of what is going on between the points.
The other graph which I presume is from Simulink will be using a sample-hold plotting such that it will plot the same value over time until it changes. This is equivalent to the stairs function in MATLAB.
• @Yaakov "This is equivalent to the stairs function in MATLAB" – Tom Carpenter May 12 at 10:46