MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Myrthe B.
0

GUI varargout does not update

Myrthe B.
さんによって質問されました 2019 年 2 月 7 日
最新アクティビティ Rik
さんによって 回答されました 2019 年 2 月 7 日
I've build a GUI that let users manually adjust a segmentation. However, varargout only 'captures' the first correction made. Any other corrections are not represented in my final output. My varargout function looks as follows:
function varargout = Clean_images_OutputFcn(hObject, ~, handles)
handles=guidata(hObject);
uiwait
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varargout{1} = handles.MC_segmentation;
varargout{2}=handles.figure1;
uiresume
Furthermore, I have an callback and pushbutton to close the GUI.
% --- Executes on button press in Push_end.
function Push_end_Callback(hObject, eventdata, handles)
handles=guidata(hObject);
uiresume
varargout{1} = handles.MC_segmentation;
delete( handles.figure1)
How can I constantly keep updating my output?

  5 件のコメント

Rik
2019 年 2 月 7 日
Outputs do not dynamically update in Matlab. You could probably design a class that does that. That might work like this: have a property in that class containing your segmentation, and then have a getter method that attempts an update by loading the guidata. If the update fails becose the GUI was closed you can return the previously loaded result, and otherwise you update your stored property as well.
Myrthe B.
2019 年 2 月 7 日
Geoff,
I have two buttons and callbacks for the manual correction of the segmentation. Each time I push the button this is updated. This works fine, which I know because I show the correction in realtime.
Rik and Adam, I'll will look into your thoughts!
Myrthe B.
2019 年 2 月 7 日
For now, I fixed it by saving the end result in a .mat file and loading this after closing my gui. Not the prettiest solution, but it works.

サインイン to comment.

1 件の回答

Rik
回答者: Rik
2019 年 2 月 7 日
 採用された回答

Instead of using the slow disk to save and store data, you could use setappdata instead. Since you wish to close the figure, you should use the graphics root as your target object. The class I described in a comment could use a similar structure as well if you prefer.
%in your GUI
setappdata(0,'MC_segmentation',handles.MC_segmentation)
%in your code afterwards
MC_segmentation=getappdata(0,'MC_segmentation');

  0 件のコメント

サインイン to comment.



Translated by