Evaluate Simulink model at a given time vector

12 ビュー (過去 30 日間)
Daniele Venanzetti
Daniele Venanzetti 2021 年 12 月 21 日
Hi all,
I have a Simulink model that I run from Matlab and I also use the block "from workspace" to load some data. As you know, I also have to load the time stamp alongside the data I want to use.
Now, I need to enforce Simulink to evaluate the model at the times stated in the block "from workspace". Ideally, this wouldn't require any interpolation in the block "from workspace".
Example:
I load this dummy DATA in my model
DATA = [0, 0;...
1, 10;...
1.3, 18;...
2.1; 21]
where [0, 1, 1.3, 2.1] is the time stamp and [0, 10, 18, 21] is the vector I need. I want Simulink to evaluate the model exactly at times [0, 1, 1.3, 2.1]. It's like a very special variable time step that I would like to enforce.
I hope I have explained clearly what I need.
Thank you everyone in advance!

回答 (1 件)

Salman Ahmed
Salman Ahmed 2021 年 12 月 31 日
Hi Daniele,
Assuming you wish to produce the simulation outputs at specified times, navigate to the model configuration settings under Data Import/Export option, find "Output Options" in Additional Parameters. Set this parameter to "Produce specified output only". Then you can specify the "Output Times" array for which you want to produce the output.
  1 件のコメント
Daniele Venanzetti
Daniele Venanzetti 2022 年 1 月 5 日
Hi Salman,
It's exactly what I was looking for! anyway, it seems that I can't fill in the tab with a variable from the workspace. I have an array "time_vec" in my workspace and if I type "time_vec" in "Output Times", it doesn't read it. It says "Invalid OutputTimes specified in the Configuration Parameters dialog for block diagram".
Maybe I could work it around by setting this parameter programmatically from Matlab. I tried running this line of code:
simOut = sim('SimExample', 'OutputOption', 'SpecifiedOutput', 'OutputTimes', 'time_vec');
Where SimExample is the simulink model.
where time_vec is my double array but when I run it, it says:
'Invalid OutputTimes specified in the Configuration Parameters dialog for block diagram SimExample'.
Do you have an idea of what I am doing wrong?
many thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by