Borrar filtros
Borrar filtros

delay time - s function

9 visualizaciones (últimos 30 días)
Kh zaa
Kh zaa el 26 de Ag. de 2018
Comentada: Aquatris el 10 de Sept. de 2018
hello sir, i use level 1 S-Function in my simulink model. I need s function to wait for 2 sec, then collects the measurements. How i can do that ?
  4 comentarios
Aquatris
Aquatris el 27 de Ag. de 2018
You can use a switch block. The two inputs to the switch can be "constant 0" and the actual signal. Then you will attach "clock" block to the decider and set the switch block to give constant 0 as output if t < 2 and actual signal if t > 2.
Kh zaa
Kh zaa el 5 de Sept. de 2018
dear Aquatris, my model is very complex with more than 350 measurements. i need to make delay inside S function. thanks

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Ag. de 2018
Aquatris's solution is the correct one in many cases.
However, if you are feeding into a controller, then the controller might be taking the differentiation, and the sharp change between 0 and non-zero would be a problem for differentiation. Therefore for you situation you should probably instead use an enabled subsystem https://www.mathworks.com/help/simulink/ug/enabled-subsystems.html, in which the control signal is the output of a comparison block between the clock and a constant block which is the enable time.
  5 comentarios
Kh zaa
Kh zaa el 10 de Sept. de 2018
kind reminder
Aquatris
Aquatris el 10 de Sept. de 2018
You can also use a "rate transition" block, which samples the signal in a different time than the simulation time. See image below where I use a sine wave as the source signal and the rate transition block allows to sample it every 2 sec (Zero order hold) and ignores the changes if 2 sec had not passed. Is this what you are trying to achieve?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by