GUI plot listening to several components value chage
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Adam
el 7 de Feb. de 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( ... )
Respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!