我已经以编程方式(不在GUIDE中)构建了一个GUI,它接受来自用户的大量输入。它被另一个脚本调用(在另一个.m文件中)。 GUI返回3个变量。
[X Y Z] = MyGUIfunction(Arg1);
我的问题是调用脚本的执行似乎在MyGUIfunction完成之前继续执行(并返回变量)。
MATLAB返回错误消息:
Output argument "X" (and maybe others) not assigned during call to "etcetc\MyGUIfunction"
此错误消息为true,X Y和Z未设置,直到用户完成输入并关闭图形。
如何在确定X Y和Z之前阻止调用脚本继续?我已经使用了uiwait(),但无法获得所需的行为。
编辑2016-06-27
此功能:
function TempDelete_2()
%Would actually like to call this and WAIT for arguments to be returned
[rX rY rZ] = TempDelete_1();
%Matlab throws error here because rX, rY and rZ have NOT been set
disp(rX)
disp(rY)
disp(rZ)
end
调用此函数:
function [X Y Z] = TempDelete_1()
fH = 550;
fW = 900;
fL = 280;
fB = 280;
h_baseFig = figure('menubar','none','Position',[fL , fB, fW, fH],'name','Create Init','NumberTitle','off','ResizeFcn',@InitFigCB_SizeChangedFcn);
%Ok Button
f_okBut = uicontrol(h_baseFig,'style','pushbutton','position',[fW-90 10 80 35],'string','OK','Callback',@CB_OKdone);
function CB_OKdone(~,~,~)
X=1;
Y=2;
Z=3;
close(h_baseFig);
return
end
end