simulink and m file connection

i have genetic algorithm written in m file and i want to run simulink from m file then read from simulink to m file the problem here is that i don't know how to read this value before the genetic algorithm running

2 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 22 日
How result in m-file is used in Simulink?
mado
mado 2013 年 3 月 22 日
the result of m file will be used in simulink after m file finished its iteration

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

回答 (4 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 22 日
編集済み: Azzi Abdelmalek 2013 年 3 月 22 日

1 投票

In simulink model use from workspace block to read data from workspace and to workspace block to export data to workspace

6 件のコメント

mado
mado 2013 年 3 月 22 日
from workspace will send data after simulink have stopped but i need data before running m file as it depends on that variable after m file ends it will update simulink
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 22 日
編集済み: Azzi Abdelmalek 2013 年 3 月 22 日
Then Run your simulink model using to workspace block.
mado
mado 2013 年 3 月 22 日
from or to workspace are the same i can't use data till simulink finished running
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 22 日
This is not clear, can you explain ?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 22 日
編集済み: Azzi Abdelmalek 2013 年 3 月 22 日
Ok then use Interpreted Matlab function block or Matlab function block (for code generation)
mado
mado 2013 年 3 月 22 日
編集済み: mado 2013 年 3 月 22 日
why ?could you explain my code is colmplex and it contain calling function

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

Jason Ghidella
Jason Ghidella 2013 年 3 月 25 日

1 投票

What you need to do is use set_param end to set the values of Simulink parameters from the GA objective function, and have an outport on the signal you want to read in the GA onjective function. Then you run the Simulink model using the sim function, and then look at the simulation output to get the value.
This video shows how to do this:
mado
mado 2013 年 3 月 22 日

0 投票

for example if i used to workspace and i ran simulink the data won't be sent to workspace untill the simulink stopped
Ramya
Ramya 2016 年 10 月 6 日

0 投票

can anyone tell me how to use the optimised values from the m file in simulink?

カテゴリ

タグ

質問済み:

2013 年 3 月 22 日

回答済み:

2016 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by