Simulink Signal-Logging

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulink Signal-Logging

Simulink Signal-Logging



Often users put many 'To Workspace' sink blocks throughout their schematic. However, they may be best served by using Simulink’s signal logging features. (See “Logging Signals” in Simulink Help which explains all).

You can turn on signal logging for individual signals without the need for any ‘To Workspace’ Blocks, or you can just enable logging for a scope, of course. (In both cases name your signals appropriately first). You can do this programmatically, so could, for example, write a script that will turn on signal logging for all signals in a given subsystem if desired.

You can then access them and plot, analyse etc – using Fixed Point Toolbox functions if desired. E.g.


e/e5/Scoping_example.PNG

Here I’ve logged Sim_Sum and dspba_sum

I can then do, for example,

>> logsout


logsout =


Simulink.ModelDataLogs (fixedptlogtest):

Name Elements Simulink Class

dspba_Sum 1 Timeseries

Sim_Sum 1 Timeseries

Or you access by subsystem Simulink.SubsysDataLogs, or by signals logged via a scope Simulink.ScopeDataLogs

>> data = logsout.('dspba_Sum')

Name: 'dspba_Sum'

BlockPath: 'fixedptlogtest/Subsystem'

PortIndex: 3

SignalName: 'dspba_Sum'

ParentName: 'dspba_Sum'

TimeInfo: [1x1 Simulink.TimeInfo]

Time: [1001x1 double]

Data: [1001x1 embedded.fi]


>> data = logsout.('dspba_Sum').Data


data =


0

0

0

0

0

0

0

0

0

0

0

0.0314

0.0626

0.0937 (etc)


>> max(logsout.('dspba_Sum').Data)


ans =


1.3141


DataTypeMode: Fixed-point: binary point scaling

Signedness: Signed

WordLength: 19

FractionLength: 14


>> plot(logsout.('dspba_Sum').Time,logsout.('dspba_Sum').Data)


Note that one thing that you can’t really do with this is make use of the override features of the fixed point type to identify underflow & overflows – this is because DSPBA explicitly does the maths according to the output type using its own internal format and constructs the result accordingly, rather than do the math using Fixed point types directly

For example, if you change the fixed point preferences :

>> fipref

ans =

NumberDisplay: 'RealWorldValue'

NumericTypeDisplay: 'full'

FimathDisplay: 'full'

LoggingMode: 'Off'

DataTypeOverride: 'ForceOff'


>> fipref.LoggingMode = 'On'

fipref =

LoggingMode: 'On'


>> fipref.DataTypeOverride = 'ScaledDoubles'

fipref =

LoggingMode: 'On'

DataTypeOverride: 'ScaledDoubles'

The Simulink Sum block will record an overflow,

Warning: Overflow occurred. This originated from 'fixedptlogtest/Sum'.

but none of the DSPBA blocks will.

Version history
Last update:
‎06-26-2019 09:36 PM
Updated by:
Contributors