MATLAB: How to access the workspace outputs like Logged Signals, States, Outputs or Inputs when I use the SIM function in Simulink 7.9(R2012a)

outputssavesimulinkstatestoworkspace

I am running the demo Simulink model 'vdp' using the SIM function and I have enabled the 'Signal Logging' check box in the Configuration Parameters to log the signal 'x2' to the base workspace. However,I am not able to access the signal using the SIM function.

Best Answer

To access the signal logged to the workspace, refer to the following code .
>> simout =sim('vdp_signallogged','SignalLogging','on','SignalLoggingName','logsout_test')
>> simout.get('logsout_test') % To access the logged signal 'x2'
Simulink.ModelDataLogs (vdp_signallogged):
Name Elements Simulink Class
x2 1 Timeseries
>> simout.get('logsout_test').x2 % To access the properties of 'x2'
Name: 'x2'
BlockPath: 'vdp_signallogged/x2'
PortIndex: 1
SignalName: 'x2'
ParentName: 'x2'
TimeInfo: [1x1 Simulink.TimeInfo]
Time: [64x1 double]
Data: [64x1 double]