Problems with sim command in Matlab 2020a

조회 수: 6(최근 30일)
Buddy
Buddy 2020년 10월 12일
댓글: stozaki 2020년 10월 13일
I am using a simulation model whcih has a To Workspace block named Results. In the Configuration Parameters dialog, the option 'Single Simulation Output' is not checked.
The thing is that when I click the Run button, I see that the Results variable is correctly generated in the workspace of Matlab. However, when I run the same simulation using the sim command from Matlab, the variable Resutls is not created but an object variable of type SimulationOutput named 'ans'.
May anyone help me with this. Thanks in advance.
  댓글 수: 2
stozaki
stozaki 2020년 10월 13일
Hi,
Do you set the return value of sim (mdl_name,'StopTime', '5') ;?
results = sim (mdl_name,'StopTime', '5') ;.
"ans" is the default return value if you have not set a return value.
stozaki

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

답변(1개)

stozaki
stozaki 2020년 10월 12일
Hello
Is the result of the following command ”ans” ?
get_param (bdroot (gcs),'ReturnWorkspaceOutputsName')
If you turn on the value of the "Single simulation output" property, you will get the signals, states, outputs, etc. all in one output object. If you turn off the value of the "Single simulation output" property, you will get each output individually.
Since you are using the To Workspace block, you can get the value of Workspace by accessing the Data property from the ans object.
result = ans.simout.Data
You can also get the time data from the ans.tout property.
times = ans.simout.Time
Please also refer to what I have answered in the past.
stozaki
  댓글 수: 2
stozaki
stozaki 2020년 10월 13일
Hi,
Do you set the return value of sim (mdl_name,'StopTime', '5') ;?
results = sim (mdl_name,'StopTime', '5') ;.
"ans" is the default return value if you have not set a return value.
stozaki

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by