Problem with Simscape variable visibility

5 ビュー (過去 30 日間)
Fabio Freschi
Fabio Freschi 2021 年 1 月 19 日
コメント済み: Fabio Freschi 2021 年 1 月 28 日
Hi all,
I have created a simulink model of a circuit using simscape electrical elements. I have also created two callbacks, InitFcn and StopFcn to initialize some parameters and postprocess the results, respectively. In particular, the initialization function randomly sets the value of some parameters used by the simulink model, whereas the StopFcn callback takes the results in the log of simulation data (those available in Simscape Results Explorer) and analyze them, saving the results on a file.
Everything runs smoothly if I start the simulation within Simulink pressing the run button.
In order to automatize the study, I have created a simple matlab script to run the model multiple times. The script is really simple and looks like this
for i = 1:10
% run simulink
sim('threePhaseDiodeRectifierFilterVariable');
end
At this point I have problems because Matlab returns an error that I can't read correctly:
Error using modelSweep (line 3)
Error evaluating 'StopFcn' callback of block_diagram 'threePhaseDiodeRectifierFilterVariable'.
Callback string is 'threePhaseDiodeRectifierFilterVariable_output'
Caused by:
Error using modelSweep (line 3)
Unable to resolve the name
out.simlog_threePhaseDiodeRectifierFilterFiveCoils.Current_Sensor_Three_Phase.I_output.series.values.
I tried to debug the code, setting a breakpoint before loading the simulation data from the variable 'out...', but this variable does not exist anymore. I think the problem is related to the visibility of the simscape data that are no longer available when the simulink model is run with the command sim, but this is only my guess and I don't know how to figure out the solution.
Does anybody have an idea of what's happening?
Thank you in advance
Fabio

採用された回答

Fangjun Jiang
Fangjun Jiang 2021 年 1 月 20 日
編集済み: Fangjun Jiang 2021 年 1 月 24 日
If I remember it correctly, all you need to do is to give sim() a return variable. Just try it
result=sim('threePhaseDiodeRectifierFilterVariable');
now I found the reference
  1 件のコメント
Fabio Freschi
Fabio Freschi 2021 年 1 月 28 日
Fangjun,
I am very sorry for my late reply. Unfortunately, your solution didn't solve initially my problem, but it was my fault. I tried multiple times and in the and I figured out where I was wrong.
This is indeed the solution I was looking for. Thank you for you help
Fabio

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by