0
請,我有這段代碼涉及到保存gui(使用道格赫爾)的方法。 問題是腳本編譯好了,但只有彈出並消失,當我運行它,使用deploytool。我正在使用Matlab R2012b。部署MATLAB文件不會開始
function savestate3
S.fh=figure('NumberTitle','off',...
'Visible','on','Position',[360 400 450 285],...
'closerequestfcn',{@fh_crfcn});
S.tg(1)=uicontrol(S.fh,'Style','toggle','String','Semester',...
'pos',[15 250 100 25],'val',0,'visible','on');
S.tg(2)=uicontrol(S.fh,'Style','toggle','String','Details',...
'pos',[135 250 100 25],'val',0,'visible','on');
S.ed(1)=uicontrol(S.fh,'Style','edit','String','Edit Text',...
'pos',[250 70 100 25],'visible','off');
S.lb(1)=uicontrol(S.fh,'Style','listbox','String',{'One','Two','Three'},...
'pos',[100 170 100 70],'visible','off');
S.cb(1)=uicontrol(S.fh,'Style','checkbox','Value',1,'String','Check Me',...
'pos',[250 170 100 25],'visible','off');
set(S.tg(:),'callback',{@tg_call,S})
guidata(S.fh,S)
restoreState(S);
function saveState(handles)
state2.editstr=get(S.ed(1),'String');
state2.listval=get(S.lb(1),'value');
state2.checkval=get(S.cb(1),'value');
save state1.mat state2
end
function restoreState(handles)
load 'state1.mat' 'state2'
set(S.ed(1),'string',state2.editstr,'FontSize',12,'FontWeight','bold');
set(S.lb(1),'value',state2.listval);
set(S.cb(1),'value',state2.checkval);
end
function fh_crfcn(varargin)
saveState(S)
delete(S.fh)
end
%TOGGLE OPERATIONS
function []=tg_call(varargin)
%Toggle Operations
[h,S]=varargin{[1,3]};
if get(h,'val')==0
set(h,'val',1)
end
switch h
case S.tg(1)
set(S.tg(2),'val',0)
set(S.ed(1),'visible','on')
set(S.lb(1),'visible','on')
set(S.cb(1),'visible','off')
saveState(S)
case S.tg(2)
set(S.tg(1),'val',0)
set(S.cb(1),'visible','on')
set(S.ed(1),'visible','off')
set(S.lb(1),'visible','off')
saveState(S)
end
end
end