how to get simulink model outputs simultaneously(when the simulation is running)?

21 ビュー (過去 30 日間)
Selim
Selim 2015 年 4 月 1 日
コメント済み: liqun fang 2022 年 11 月 7 日
I have a simulink model that have the outputs x and y. When i run the simulation they give me 500x1 double values. x values are reference values and y values are the outputs that i want to converge them to x. I used genetic algoirthm to optimize output y. There are 5 parameters to optimize outputs y. I want to get x and y values to calculate error(MSE, MAPE , ITAE vs.) for cost function of genetic algorithm. Is there any method to get these output values from simulink to .m file(genetic algorithm runninng in this file) when simulation is running . From .m file to simulink i can adjust the 5 parameters simultaneously by 'set_params' but i can not find for the exact opposite situation.

採用された回答

Selim
Selim 2015 年 4 月 1 日
I solved the problem. I used to matfile from the sinks library and created the subsystem for this block. Then i masked the subsystem as parameter -- Inherit: Same as output Parameter name must be the same with output name . In my genetic algorithm .m file i used
y = get_param('my_model/y','y') %y is also subsystem name
it works. After running the simulation i get the y values each iteration to send ga .m file for optimization.
  1 件のコメント
liqun fang
liqun fang 2022 年 11 月 7 日
Hi Selim, Can you explain the operation in detail? I have the same needs. Thank you..

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

その他の回答 (3 件)

Dishant Arora
Dishant Arora 2015 年 4 月 1 日
You can bring or save simulation results to your workspace by making use of following blocks.
1.) to workspace form the sinks library
2.) to matffile from the sinks library
You can also make use out1(outport) block
  2 件のコメント
Ilham Hardy
Ilham Hardy 2015 年 4 月 1 日
It doesn't meet the requirement : when simulation is running
Selim
Selim 2015 年 4 月 1 日
i tried to use to workspace block, but when i run the simulation i get 'undefined function or variable y' error. i will try to matfile, if it works i'll write about it. Many thanks.

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


Ilham Hardy
Ilham Hardy 2015 年 4 月 1 日
To meet the requirement, you might want to integrate your GA mfile to simulink (e.g. using Matlab Function block).

Jishnu Mukherjee
Jishnu Mukherjee 2018 年 9 月 24 日
you can try and use matlab function block and log the output of the block and check the result in simulink data inspector while simulation is running

カテゴリ

Help Center および File ExchangeSimulink Design Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by