I don't understand the concept of sample time in simulink

2 views (last 30 days)
I had a simulink block(a constant block=2) connected to an output port(yout). I set a 'fixed step size' of 0.2 in the 'configuration parameters' dialogue box. I was thinking that if i set the constant block to a sample time of 0.4, the constant block should execute at every second sumulation time step since 'fixed step size' is 0.2. But when i ran the model for a stop time of 0.8(ie for 5 'time steps' including 0) i got yout=[0;2;2;2;2] meaning that the block executed 5 times. What i was expecting was for the block to execute only 3 times so that yout=[2;2;2].
So I concluded that I do not understand the concept of sample time. I will appreciate it if anyone could help explaining the above result and the general concept of sample time.
Thanks you in advance. Bethel

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 16 Dec 2011
In this case, since you are looking at the logged data yout, the sample time is determined by the sample time specification of the Outport block. If you change the sample time of the Outport block, you'll see the difference.
For general information regarding sample time in Simulink, see Sample Times
  6 Comments
bethel o
bethel o on 19 Dec 2011
Thank you very much. I think I understand it now. Well thats if the following is right: In the solver panel for the 'configuration parameter' dialogue, i saw a check box for 'Automatical handle rate transition for data transfer'. The check box was un-checked. I checked the box and ran the model again. I noticed that yout was being delayed by the value of its sample rate.
Maria Sheeba
Maria Sheeba on 22 Feb 2017
when I ran the setup I get the following error "The sample time 1 of 'G722_ITU_T_Codec/Multiport Switch' at input port 2 is different from the sample time 2.083333333333333e-05 of 'G722_ITU_T_Codec/Random Source' at output port 1. Consider inserting a Rate Transition block between the two ports. Alternatively, you can control the diagnostic action for unspecified rate transitions by changing the option "Multitask (or Single task) rate transition" on the Sample Time Diagnostics pane of the Configuration Parameters dialog box."

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!