programmatically change simulink scope plot line visibility

6 次查看(过去 30 天)
Hello,
I have been searching all day for this on Google and on here. I found two old, existing questions asking for the same thing, with no joy. They are here:
What I would like to do is programmatically interact with the floating Simulink scope window from the Matlab command line, specifically to change the visibility of lines plotted on it. I am aware I can request the configuration of the Scope and interact with it to a degree (https://uk.mathworks.com/help/simulink/ug/control-scopes-programmatically.html), but that did not include any method to toggle line visibility. Anyone have any bright ideas please?

回答(1 个)

Pratyush Swain
Pratyush Swain 2024-5-23
编辑:Pratyush Swain 2024-5-27
Hi Robyn,
I understand you want to change the visibility of lines plotted on scope block programmatically.I also could not find any documented resource to toggle the input lines on scope block. You can consider some workarounds for this issue as follows:
1- Conditional Signal Routing: Use Simulink's conditional signal routing blocks (such as Switch, Multiport Switch, or Manual Switch) to control which signals are fed into the scope. By controlling the routing block's condition programmatically, you can "turn off" certain signals.
Please refer to this demo example for reference:
% Access the control signal block for multiport and set its value
% (In this case we are selecting between 3 inputs so values can be 1-3)
set_param('multiport/Control Signal', 'Value', '2');
% Place name of simulink model file: I have kept it multiport
sym('multiport')
If you specifically want to toggle set of input lines as a group,you can consider controlling it by passing it through "enabled subsystems" block and controlling the "enable signal" programmatically.
2- Using Simulink Data Inspector Tool: The above approach still has some limitations placing conditions on all signals individually.If you do not want to make changes to your simulink model repeatedly and only toggling the lines programmatically is not a constraint, you can consider using simulink data inspector tool to log and visualize the signals, it offers a variety of options to visualize data by selecting signals and comparing different signal datas. For more information please refer to https://www.mathworks.com/help/simulink/slref/simulationdatainspector.html
Hope this offers some help.

类别

Help CenterFile Exchange 中查找有关 View and Analyze Simulation Results 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by