0
votes

I want to create a similar figure with Simulink like:

Figure 1
Figure-1

This is my MATLAB code:

n = importdata('n.txt',';')
cars = n(:,2)
trucks = n(:,3)
bus = n(:,4)
t = linspace(1,365,365)
t = transpose(t)

Here are my Simulink blocks:

Figure 2
Figure-2

And "Scope" block does this kind of figure:

Figure-3
Figure-3

Why is Simulink figure (Figure-3) not similar to Figure-1. I want to create a similar figure with Simulink. Where is the problem?

1
How do I set the axis settings that it looks like right?engineerstudent

1 Answers

2
votes

Note that the t(ime) vector that defines your input data has no effect on the length of time that the simulation runs - it purely defines the shape of your input data.

By default, the Stop Time for a Simulink model is 10 seconds, which is why your second figure only runs out to 10 seconds. Your model is only reading/simulating the first 10 seconds of data. Change the Stop Time (across the top of the model's window) to be either 365, or even better max(t). (In the latter case, if you subsequently change t in the MATLAB Workspace then the simulation stop time will change accordingly too, without you having to manually change anything in the model.)

By default the Scope will show all of the simulated data. But if it doesn't (or you zoom at any time) then you can use the zoom tools (across the top of the Scope) and various of the Scope Properties to change the amount of data you see.