필터 지우기
필터 지우기

Creating a Responsive GUI Within Simulink

조회 수: 4 (최근 30일)
Luke Dillon
Luke Dillon 2018년 9월 5일
댓글: Luke Dillon 2018년 9월 6일
Hi All,
I recently made a small app in App Designer where the user could provide inputs via switches/buttons, and a number of responses could be observed.
Some of these responses were a lamp changing colour from red to green, some were text changing from grey to red, and some were a textbox/area becoming visible/invisible for example.
I am now attempting to recreate the same app using Simulink and Stateflow, as Stateflow allows for more efficient behavioural modelling.
For the GUI I've used dashboard blocks (lamps, text areas etc.) and for the lamps changing colour, it's as simple as connecting them to the right output from the model.
However, I'm struggling to find a way to get text to change colour in response to a signal, or for an area to appear/disappear, etc. For example, say I've got a line of text that says 'WARNING', and it starts greyed out. I'd like it to turn bright red when the user presses a certain Dashboard button/switch.
In App Designer I was able to do this using callbacks, and I'm just wondering if anyone knows the method for doing the same in Simulink?
Many thanks!

채택된 답변

Sara Nadeau
Sara Nadeau 2018년 9월 5일
Hi Luke,
What version of MATLAB/Simulink are you using? I think there are a couple blocks that could help you.
If your version is R2016b or later, you could use the MultiStateImage block as a responsive indicator. You would connect the MultiStateImage block to the signal you want to control its state and you could upload an image for each state. For example, the image could be of the text you want to display (WARNING) in different colors, depending on the state. The MultiStateImage block works very similarly to the Lamp block while allowing much greater control over the appearance.
If your version is R2017b or later, you can call a callback function from your dashboard with the Callback Button block. A callback function that you specify in the block dialog executes when you press the button. You can define separate functions for a 'click' (short press) and a 'press' (holding the button for an amount of time you specify).
  댓글 수: 1
Luke Dillon
Luke Dillon 2018년 9월 6일
Hi Sara,
I'm on MATLAB 2018a, so I could potentially use callbacks - however, I didn't know about the MultistateImage block! I've just tried it out and it seems to work much better for my model - just the kind of thing I was after.
Many thanks for the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by