Simulink SimulationOutput aaccess via Code

4 views (last 30 days)
Jakob Mohr
Jakob Mohr on 12 Oct 2021
Answered: Chetan Bhavsar on 12 Oct 2021
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:
Is the only way to access the whole structure by the following code?:
temp = ans;
Many Thanks

Answers (1)

Chetan Bhavsar
Chetan Bhavsar on 12 Oct 2021
[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 =
Simulink.SimulationOutput: simout1: [1x1 timeseries] simout2: [1x1 timeseries] tout: [51x1 double] yout: [1x1 Simulink.SimulationData.Dataset] SimulationMetadata: [1x1 Simulink.SimulationMetadata] ErrorMessage: [0x0 char]
timeseries Common Properties: Name: '' Time: [51x1 double] TimeInfo: tsdata.timemetadata Data: [51x1 double] DataInfo: tsdata.datametadata
ans = 51×1
0 0.0998 0.1987 0.2955 0.3894 0.4794 0.5646 0.6442 0.7174 0.7833

Community Treasure Hunt

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

Start Hunting!