GUI plot listening to several components value chage
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Adam
2018-2-7
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( ... )
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!