Simulink SimulationOutput aaccess via Code

1 Ansicht (letzte 30 Tage)
Jakob Mohr
Jakob Mohr am 12 Okt. 2021
Beantwortet: C B am 12 Okt. 2021
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

Antworten (1)

C B
C B am 12 Okt. 2021
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

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by