How do I access the DocUnits and Description of the virtual signals being passed into a subsystem in a report template for Simulink Models in Simulink 7.7 (R2010b)?

1 view (last 30 days)
I would like to summarize the signals coming into and going out of each subsystem in my Simulink model as part of a template for Simulink Report Generator. I need to access fields in the virtual signals such as 'DocUnits' and 'Description'. However, I noticed that the report generator does not include these fields by default.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 11 Oct 2021
Edited: MathWorks Support Team on 17 Nov 2021
The ability to access the 'DocUnits' and 'Description' fields of the virtual signals being passed into a subsystem in a report template for Simulink Models in Simulink 7.7 (R2010b) is not available.
To workaround this issue follow the steps below:
In order to include information like this in a report, you must create a script that you will use in an ‘Eval’ component in your report template that evaluates a MATLAB expression. The code included in this component will reflect the information that you are looking to view in the report. There is no built-in component in the Report Generator that provides information on fields in virtual signals such as DocUnits and Description.
The way to access the fields associated with the Simulink Signal object is to look at the object in the workspace using the EVALIN command. For this, it is only required that you know the name of the signal, which is possibly the same name as the Inport. There may be special considerations in getting signal data from subsystem, here are some example considerations and precautions:
1. You should check to see if the 'MustResolveToSignalObject' property of the source port of the corresponding line is ‘on.’ If the model design is very uniform and all lines are assumed to have this property, then this step may be unnecessary, but it is still recommended. When you are listing properties of the Outport of a subsystem, you may access this property directly, but when you are listing properties of the Inport of a subsystem, you must find each port’s Source Outport and check the properties of that port.
2. The 'MustResolveToSignalObject' is associated with the original source block. If the signal is propagated through multiple subsystems, then the original source block will be more than one link away. The name of the signal may be accessible through the ‘PropagatedSignals’ property of the next immediate source block, but getting to the 'MustResolveToSignalObject' field may take more than one step.
3. There are rate change blocks that interrupt the path from Source port to Inport. A user can manually insert these in a model, but it is also possible that SIMULINK inserts invisible rate change blocks to accommodate timing features of the model. Confirming the 'MustResolveToSignalObject' status of the Source Port or the ‘PropagatedSignals’ information may be difficult to do programmatically in this case.
4. You could confirm that the variable with a specific name exists in the workspace.
index = strmatch(SignalName,evalin('base', 'who'),'exact');
If Index has any value then the variable exists.
5. You could confirm that the variable with a specific name exists in the workspace, and verify that it is of class ‘Simulink.Signal.’
VarClass = getfield(whos(SignalName),'class');
If VarClass is a string with ‘Simulink.Signal’, then you have a ‘Simulink.Signal’ object.
There are a few options for formatting the strings in the report once you have the information you are looking for:
SPRINTF: https://in.mathworks.com/help/matlab/ref/sprintf.html
DISPLAY:https://in.mathworks.com/help/matlab/ref/display.html
EVALC: https://in.mathworks.com/help/matlab/ref/evalc.html
Attached is an example model and MATLAB code that demonstrates how to find the field information of a Simulink.Signal object associated with a model.

More Answers (0)

Categories

Find more on Manual Performance Optimization in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2010b

Community Treasure Hunt

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

Start Hunting!