Simulink SimulationOutput aaccess via Code

조회 수: 1 (최근 30일)
Jakob Mohr
Jakob Mohr 2021년 10월 12일
답변: C B 2021년 10월 12일
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