GUI plot listening to several components value chage

2 vues (au cours des 30 derniers jours)
Huayan Wang
Huayan Wang le 7 Fév 2018
Commenté : Huayan Wang le 7 Fév 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 commentaires
Adam
Adam le 7 Fév 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 le 7 Fév 2018
Thank you Adam!
That helps.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by