Getting the simulation time

1 visualización (últimos 30 días)
Aditya
Aditya el 6 de Oct. de 2012
Hi,
I am using a manual switch in my model. During simulation if i click the switch manually and switch the input i call a script.In the script i want to know that particular simulation time step when i switched my input.
I am unable to find the simulation time step.Please help

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 6 de Oct. de 2012
Editada: Azzi Abdelmalek el 6 de Oct. de 2012
Use Interpreted Matlab function blocks with the below code
function y=get_sw(u)
y= str2num(get_param('YourModelName/Manual Switch','sw'))
The result is 1 or 0
%
  2 comentarios
Aditya
Aditya el 6 de Oct. de 2012
I want to find the time step when the switch undergoes transition.
This code doesn't provide me the time step.
Azzi Abdelmalek
Azzi Abdelmalek el 6 de Oct. de 2012
use a clock block from 'simulink/sources'. You will have time t and the state of your switch y
in Matlab command after simulation
steptime=t(find(diff(y)~=0))

Iniciar sesión para comentar.

Categorías

Más información sobre Modeling en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by