MATLAB: Simulation time” and Sampling time

simulinktime

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

Best Answer

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".