- Add a ‘Push Button’ block from the Simulink Library Browser (Simulink/Dashboard).
- Right click the “Push Button” block and click properties.
- In the Porperties console, click on the callback tab.
- Configure a callback for the Button Block under “OpneFcn” Callback using the following code snippet:
how do the Simulink examples open close scopes using a button
3 views (last 30 days)
Show older comments
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 :(
0 Comments
Answers (1)
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:
%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.
0 Comments
See Also
Categories
Find more on Model, Block, and Port Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!