How to automatically update MATLAB GUI axes handles?

4 views (last 30 days)
Hello,
I created an application with MATLAB GUI that has several sections, each section has multiple push buttons, and at the end of each there is a figure that needs to be updated.
My question is: how can I pass the output of a callback function to the figure handle so that it gets updated as soon as the output is produced?
The figure is a scattered plot of a point cloud data, what I want is for example when I load in a file, it automatically shows the raw data (say OUTPUT = RAW), then when I process the data it should automatically update the figure with (OUTPUT = Processed). Without writing a few lines again to pass the Processed to figure handle.
Any help is much appreciated.

Accepted Answer

Steven Lord
Steven Lord on 20 Feb 2020
Callback functions don't have outputs, at least not how they are called by the usual workflow of a UI in MATLAB.
I'd probably write a function that your pushbutton callbacks can use to set the status message appropriately, something like:
function setStatusMessage(f, newmessage)
f.statusWindow.String = newmessage;
end
where statusWindow is the component in the figure that contains the status message.
That's also pretty self-documenting.
function gridSmoothedData_Callback(...)
% Do some processing on the data
setStatusMessage(f, "Processed");
% Maybe call the next step in the process
updateSmoothedDataVisualization(...);
end
Without even seeing what the function accepts can you tell the purpose of this callback, what the state of the process is when this function finishes, and what the next step is?

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!