Simulink SimulationOutput aaccess via Code

1 次查看(过去 30 天)
Hi,
in my recent tries of working with Simulink i've encountered a problem with the Block "ToWorkspace" or also known as "SimOut". The Data i am getting is just written in the "ans" variable after the Simulation and cannot be accessed by:
temp = Simulink.SimulationOutput;
either before or after the simulation start with:
sim(modelname)
Is the only way to access the whole structure by the following code?:
sim(modelname)
temp = ans;
Many Thanks
JM

回答(1 个)

C B
C B 2021-10-12
load_system('sampleModel');
[T] = sim('sampleModel');
Warning: The file containing block diagram 'sampleModel' has been changed on disk since it was loaded. Simulink is unable to reload it automatically because it is the root model. Close it and reopen it manually.
T
T =
Simulink.SimulationOutput: simout1: [1x1 timeseries] simout2: [1x1 timeseries] tout: [51x1 double] yout: [1x1 Simulink.SimulationData.Dataset] SimulationMetadata: [1x1 Simulink.SimulationMetadata] ErrorMessage: [0x0 char]
T.simout1
timeseries Common Properties: Name: '' Time: [51x1 double] TimeInfo: tsdata.timemetadata Data: [51x1 double] DataInfo: tsdata.datametadata
T.simout1.Data
ans = 51×1
0 0.0998 0.1987 0.2955 0.3894 0.4794 0.5646 0.6442 0.7174 0.7833

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by