- 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 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Arun
2023-12-29
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!