필터 지우기
필터 지우기

how do the Simulink examples open close scopes using a button

조회 수: 6 (최근 30일)
alden fuchs
alden fuchs 2022년 3월 17일
답변: Arun 2023년 12월 29일
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 :(

답변 (1개)

Arun
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:
  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.

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by