![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172086/image.jpeg)
Getting the simulation time
3 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2012 年 10 月 6 日
編集済み: Azzi Abdelmalek
2012 年 10 月 6 日
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/172086/image.jpeg)
%
2 件のコメント
Azzi Abdelmalek
2012 年 10 月 6 日
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))
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!