sim command and to workspace logging

I am trying to run a model with the following script:
Test.Config.StartTime = '0.0';
Test.Config.StopTime = '100.0';
Test.Config.SolverType = 'Fixed-step';
Test.Config.Solver = 'FixedStepDiscrete';
Test.Config.FixedStep = '1.0';
sim('TH_CrossProduct',Test.Config);
This model has a 'To Workspace' block that is supposed to be logging a timeseries to a variable called 'Test_Output'. However, using the script above, I do not get a variable called 'Test_Output', I get a 'Simulink.SimulationOutput' object which contains 'Test_Output' assigned to 'ans'. But if I run the model using the following:
sim('TH_CrossProduct')
I do get a timeseries assigned to 'Test_Output'. Because of this, I am assuming that there is some parameter that needs to be passed via the 'Test.Config' structure to the model. However, I have no idea what this might be. Can anyone provide any help?
Thanks,
Ryan

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2012년 8월 10일
편집: Kaustubha Govind 2012년 8월 10일

1 개 추천

As described on this page of the documentation, SIM returning a Simulink.SimulationOutput object is the new syntax. Getting timeseries objects directly is only possible via the Backward Compatible syntax of the SIM command, so I think you might be able to get what you need by passing in the configuration parameters as a SIMSET:
opts = simset(simget('TH_CrossProduct'),'StartTime', '0.0', ...)
sim('TH_CrossProduct', opts)
However, this syntax still exists only for the sake of backwards compatibility, so you might be better advised to use the new syntax unless your code is expected to be executed in older versions of MATLAB.

카테고리

도움말 센터File Exchange에서 Manage Design Data에 대해 자세히 알아보기

제품

태그

질문:

2012년 8월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by