Set Simulink variable with m file

조회 수: 13 (최근 30일)
Kris
Kris 2012년 6월 6일
Hello,
To be able to see how my Simulink model responds to differenct variabel values i want to set the Variable value with an m file(function).
The m file runs a for loop. In this for loop i collect data from an excel sheet wich i loaded into my workspace. Now i would like to change my Simulink model variable to the value from my excel file.
for a=1:10
HeatFactor(a,2) %the HeatFactor is an array, i retrieve data (a number)
from the second kolumn
simOut = sim( 'ABC', 'SaveOutput', 'on' )
results = simOut.get( 'yout' )
a=a+1;
end
So before i simulate i want to transfer the value i retrieve from HeatFactor(a,2). To the Variable F in my Simulink model (i used a constant block for this and set the value to F).
Also i would like to set the result of the simulation, the value i get from 'yout' into and array list. One that keeps counting and not one that get's reset everytime i speak to my model 'ABC'.
Thanks,
Kris

답변 (1개)

K E
K E 2012년 6월 6일
You can use the set_param command within a mfile script to change a parameter in your Simulink model. These answers and this link may be helpful.
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2012년 6월 6일
Regarding getting "yout" into an array, you simply have to make your "results" variable a cell-array (or something similar).
results{i} = simOut.get( 'yout' );

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by