Getting the simulation time

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

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 6일
편집: Azzi Abdelmalek 2012년 10월 6일

0 개 추천

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

Aditya
Aditya 2012년 10월 6일
I want to find the time step when the switch undergoes transition.
This code doesn't provide me the time step.
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))

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Modeling에 대해 자세히 알아보기

질문:

2012년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by