필터 지우기
필터 지우기

help with this problem please

조회 수: 1 (최근 30일)
Abdelmalek Benaimeur
Abdelmalek Benaimeur 2019년 4월 9일
답변: Abdelmalek Benaimeur 2019년 4월 10일
hellos Folks,
i'm working on appdesigner and i'm using inputdlg to ask the user to save the results to wrokspace, I'm usng this code
prompt = {'Choose the figure name','Choose the Tree name',...
'Choose the Clusters name','Choose the Roots name'};
answer=inputdlg(prompt);
if ~isempty(answer{1})
assignin('base',answer{1},app.Figure);
end
if ~isempty(answer{2})
assignin('base',answer{2},app.Tree);
end
if ~isempty(answer{3})
assignin('base',answer{3},app.Clusters);
end
if ~isempty(answer{4})
assignin('base',answer{4},app.Roots);
end
the problem is when i click Cancel button i obtain this error
Any soulutions please ?

채택된 답변

Alex Mcaulley
Alex Mcaulley 2019년 4월 10일
A good option is to use the try catch statement, then:
prompt = {'Choose the figure name','Choose the Tree name',...
'Choose the Clusters name','Choose the Roots name'};
answer=inputdlg(prompt);
try
if ~isempty(answer{1})
assignin('base',answer{1},app.Figure);
end
if ~isempty(answer{2})
assignin('base',answer{2},app.Tree);
end
if ~isempty(answer{3})
assignin('base',answer{3},app.Clusters);
end
if ~isempty(answer{4})
assignin('base',answer{4},app.Roots);
end
catch
%Some things to do if answer is not complete
end

추가 답변 (1개)

Abdelmalek Benaimeur
Abdelmalek Benaimeur 2019년 4월 10일
Thann you so much, it worked

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by