Storing the clock time into a vector in simulink
古いコメントを表示
Hi,
I wanted to know how can I use embedded matlab block in simulink to store the clock time into a vector?
I am using time clock as the input to embedded matlab block and trying to store that in a vector variable which is the output of embedded matlab block? Is this a right way to do, if not how else can I do it?
It would be of great help, if you could suggest or advise me on how to do it.
Thanks!!
3 件のコメント
Kaustubha Govind
2011 年 9 月 26 日
Do you mean that you'd like to concatenate the clock time with other signal values into a vector? Try the Vector Concatenate block.
Fangjun Jiang
2011 年 9 月 26 日
What is your goal? There might be alternatives other than using the embedded matlab function block.
Muthappa
2011 年 9 月 26 日
回答 (1 件)
Fangjun Jiang
2011 年 9 月 26 日
1 投票
For this task, I recommend not to use the Embedded MATLAB Function block. As you can see, if your simulation just started for a short period of time, you won't be able to run trapz(t(50:150),v(50:150)) because the 150th data point is not available yet. The Embedded MATLAB Function block in the Simulink model will typically run at every time step.
You can use the "To Workspace" block to log the data. Using the 'Structure with Time" save format will log the time and value at once. Once the simulation is done and the data is logged, you can post-process the data using trapz().
3 件のコメント
Muthappa
2011 年 9 月 26 日
Fangjun Jiang
2011 年 9 月 26 日
For that, maybe you can play with the persistent declaration of the variable. doc persistent
I am still thinking this approach is awkward. Can't you put an Integrator block inside a triggered subsystem and trig the subsystem at t=150 seconds.
Muthappa
2011 年 9 月 27 日
カテゴリ
ヘルプ センター および File Exchange で Programmatic Model Editing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!