How to automatically update MATLAB GUI axes handles?

조회 수: 8 (최근 30일)
Feri
Feri 2020년 2월 20일
답변: Steven Lord 2020년 2월 20일
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.

채택된 답변

Steven Lord
Steven Lord 2020년 2월 20일
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?

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by