Clear Filters
Clear Filters

how do the Simulink examples open close scopes using a button

6 views (last 30 days)
ok lots of Simulink examples have buttons to open or close a scope so you only have the screan you are intersted in up... how do i recreate the effect, i tried to copy one set of scopes and use differnt sorces but the copied buttons are connected to the original scop :(

Answers (1)

Arun
Arun on 29 Dec 2023
Hey Alden,
I understand that you want to use button to toggle the visibility (open or close) of scope in a Simulink model.
You can use a button to open or close the scope window by following the below steps:
  1. Add a ‘Push Button’ block from the Simulink Library Browser (Simulink/Dashboard).
  2. Right click the “Push Button” block and click properties.
  3. In the Porperties console, click on the callback tab.
  4. Configure a callback for the Button Block under OpneFcn Callback using the following code snippet:
%Callback for Button
if strcmp(get_param(uModel_name/Scopet, tOpeno), noni) %check if the button is on
set_param(Model_name/Scope, Open, off);
else
set_param(Model_name/Scope, Open, on);
end
Using this you can achieve the desired functionality. Enclosed is a screenshot of the attached model, which you can use for your reference:
For additional information regarding push button, please refer to the following MATLAB documentation : https://www.mathworks.com/help/simulink/slref/pushbutton.html
Hope this helps.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!