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
2012-8-10
编辑:Kaustubha Govind
2012-8-10
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 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!