시뮬레이션 결과를 단일 객체로 반환하는 방식으로 모델을 시뮬레이션하는 경우, Simulink.SimulationOutput
객체를 사용하여 모든 기록된 데이터와 시뮬레이션 메타데이터에 액세스합니다.
이 예제의 모델은 단일 시뮬레이션 출력 파라미터가 활성화되어 있고 여러 다양한 기록 방법을 사용하여 데이터를 기록합니다.
Sine Wave 블록의 출력은 신호 기록을 사용하여 기록됩니다.
Gain 블록의 출력은 To Workspace 블록을 사용하여 기록됩니다.
Gain 블록, Chirp Signal 블록, Square Wave Generator 블록의 출력은 Record 블록을 사용하여 기록됩니다.
Square Wave Generator 블록의 출력은 출력 기록을 사용하여 기록됩니다.
이 모델은 시간 데이터를 기록하도록 구성되어 있기도 합니다.
모델을 엽니다.
Simulink.SimulationInput
객체를 만들어 모델의 시뮬레이션을 구성합니다. setModelParameter
함수를 사용하여 StopTime
파라미터를 20
으로 설정합니다.
모델을 시뮬레이션합니다. sim
함수는 시뮬레이션에서 기록된 모든 데이터가 포함된 Simulink.SimulationOutput
객체를 결과로 반환합니다. 각 블록의 데이터와 각 기록 유형은 속성으로 저장되며 이 속성은 블록이나 모델에 지정된 기록 변수 이름과 일치합니다.
점 표기법, get
함수 또는 find
함수를 사용하여 기록된 데이터에 액세스할 수 있습니다.
점 표기법을 사용하여 To Workspace 블록을 통해 기록된 신호 Big Sine
에 액세스합니다.
timeseries
Common Properties:
Name: 'Big Sine'
Time: [51x1 double]
TimeInfo: [1x1 tsdata.timemetadata]
Data: [51x1 double]
DataInfo: [1x1 tsdata.datametadata]
More properties, Methods
get
함수를 사용하여 신호 기록을 통해 기록된 신호 Sine
에 액세스합니다.
logsout =
Simulink.SimulationData.Dataset 'logsout' with 1 element
Name BlockPath
____ _______________________
1 [1x1 Signal] Sine LoggingBlocks/Sine Wave
- Use braces { } to access, modify, or add elements using index.
find
함수를 사용하여 출력 기록을 통해 기록된 신호 Square Wave
에 액세스합니다.
yout =
Simulink.SimulationData.Dataset 'yout' with 1 element
Name BlockPath
___________ _____________________
1 [1x1 Signal] Square Wave LoggingBlocks/Outport
- Use braces { } to access, modify, or add elements using index.
SimulationOutput
객체의 SimulationMetadata
속성에서 시뮬레이션 메타데이터에 액세스합니다.
simmetadata =
SimulationMetadata with properties:
ModelInfo: [1×1 struct]
TimingInfo: [1×1 struct]
ExecutionInfo: [1×1 struct]
UserString: ''
UserData: []
시뮬레이션 메타데이터는 Simulink.SimulationMetadata
객체로 반환됩니다. SimulationMetadata
객체는 해당 객체 속성의 구조체로 정보를 그룹화합니다.
SimulationMetadata
객체의 ExecutionInfo
속성을 표시합니다. 실행 정보에는 경고나 오류 없이 중지 시간 20
으로 실행되는 시뮬레이션이 표시됩니다.
ans = struct with fields:
StopEvent: 'ReachedStopTime'
StopEventSource: []
StopEventDescription: 'Reached stop time of 20'
ErrorDiagnostic: []
WarningDiagnostics: [0×1 struct]