GUI plot listening to several components value chage

1 Ansicht (letzte 30 Tage)
Huayan Wang
Huayan Wang am 7 Feb. 2018
Kommentiert: Huayan Wang am 7 Feb. 2018
I have a pushbutton, radio button and checkbox to control one plot in GUI.
I would press the pushbutton to plot and then every time I do a value change to the radio button and checkbox, the plot will update accordingly.
The way I can think is to copy and paste the plot code into every component callback. But it is a pain to change the plot function. I think there must be an easy way to do so. Something like to make the component broadcast the value change and the plot function as a listener will update accordingly.
Anybody can give me a hint? Thanks in advance!
  2 Kommentare
Adam
Adam am 7 Feb. 2018
Your plot function should be factored out from the callback and simply take the inputs it needs to update the plot. This depends on what is being plotted. Ideally if it is e.g. a single line plot that updates you should plot it once, for the first time, then keep its handle, then future updates should just change the XData and YData (and any other properties that may need updating) of this line object.
Either way though you should just do something like this:
function plot( someArgs )
% do plotting update
function pushButtonCallback( ... )
% Get relevant arguments
plot( ... )
function checkboxCallback( ... )
% Get relevant arguments
plot( ... )
function radioButtonCallback( ... )
% Get relevant arguments
plot( ... )
Huayan Wang
Huayan Wang am 7 Feb. 2018
Thank you Adam!
That helps.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by