Creating a Responsive GUI Within Simulink

7 views (last 30 days)
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!

Accepted Answer

Sara Nadeau
Sara Nadeau on 5 Sep 2018
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 Comment
Luke Dillon
Luke Dillon on 6 Sep 2018
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!

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!