Reputation: 15
I want to create a similar figure with Simulink like:
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:
And "Scope" block does this kind of figure:
Why is Simulink figure (Figure-3) not similar to Figure-1. I want to create a similar figure with Simulink. Where is the problem?
Upvotes: 0
Views: 485
Reputation: 11
In Figure 1, the x-axis represents time, and we can see that it spans over a duration of 365 units. This means that the data or events captured in Figure 1 are spread out over a time period of 365 units.
On the other hand, when using Simulink to generate Figure 3, the default simulation time is set to 10 seconds. This means that the simulated system or model in Simulink is only evaluated and plotted for a duration of 10 seconds.
To make Figure 3 resemble Figure 1, where the time axis spans over 365 units, you will need to adjust the simulation time in Simulink to 365. By increasing the simulation time to match the duration seen in Figure 1, you will be able to observe the behavior or results of the simulated system over a much longer period. Adjusting the simulation time to 365 will allow you to capture and analyze the system's behavior over a timeframe that is equivalent to the duration represented in Figure 1.
Upvotes: 0
Reputation: 10762
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.
Upvotes: 2