Simulation time" and Sampling time

I am newbie to Matlab and Simulink , I am asking about "simulation time" and "sampling time" in simulink What are they ? What is the relationship between them and also the relationship between them and Real time (in real World). I hear that this simulink is run at simulation time 30 and sampling time 0.01 , What that is mean ?
thanks for all

 Accepted Answer

Orion
Orion on 22 Nov 2014
Edited: Orion on 22 Nov 2014
With Simulink, you are modeling some dynamics systems, meaning that your problem is time depending (For a physical modeling, you're gonna have differential equation to solve,...).
To see how a model behave you have to simulate it and see what happens when time increases.
at t = 0, the system is initialized.
then Simulink computes the state of your system at the next sample time 0.01s, then at 0.02, 0.03,...each step beeing updating using the previous values, and so on until the final simulation time you defined (ts = 30s).
The sample time exists, because you are in a numerical environment, not an analytic one. With a sample time too big, your model risk to diverge, and with a too small, your simulation risk to takes a really long time.
The final time is here to say to Simulink when to stop, because usually, you just want to see the evolution of your system for a defined period. But you can put inf as simulation parameter and then simulate until the end of time.
And the calculation is not happening in "real time simulation ". But the results are calculated against the "time", because you are solving a time dependant system. So if your modeling is good, then you will know how your system respond to stimuli in "real life".

4 Comments

Thanks a lot Orion
Now things become clear to me . but there is something is not , the simulation time that set in the upper bar of simulink window , what is the unit of this time ? Actually when I set this time to 50 and run simulation then when simulation ends I compare the elapsed real time (by my watch) with simulation time I found that is less then 40 , it about 13 second , so what is the explanation of that ?
Here, I made a really simple model : y''+y = 0 and y'(0) = 0.1
the stop time is set to 30s with a sample time at 0.01s.
and i solved my problem for a 30s period.
and the simulation hopefully, only takes about half a second on my machine.
There is no correlation with real time simulation.
If you want your model to run in real time, it's another problem, and let just say, it's really, really not for beginners.
Maria
Maria on 22 Nov 2014
Edited: Maria on 22 Nov 2014
Ok , I understood that and thanks a lot for you .
Hi, what is the use for variable sample time? i want to input different values each value for different duration_ i am working on control systems in wind turbine, i want to enter different values of wind speed, is it right to use step block and variable sample time?

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products

Tags

Asked:

on 22 Nov 2014

Commented:

on 3 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!