URGENT DUE AT 12AM!! Using the inputdlg, how to get the answers/inputs to be 'remembered'

조회 수: 1 (최근 30일)
this is my entire code:
while true
dlg_prompts = {'Radius','delta_time','delta_theta'};
dlg_title = 'Calculate a Mass Moment of Inertia';
dlg_defaults = {'1','.01','3'};
opts.Resize = 'on'; % a structure
dlg_ans = inputdlg(dlg_prompts,dlg_title,1,dlg_defaults,opts)
r1 = str2num(dlg_ans{1})
dtime=str2num(dlg_ans{2})
dtheta=str2num(dlg_ans{3}')
axis([-2.*r1 2.*r1 -2.*r1 2.*r1])
title('Simulating Your Rotation')
hold on
for dtheta = [0:dtheta:360];
x = r1.*cosd(dtheta);
y=r1.*sind(dtheta);
plot(x,y,'o')
pause(dtime)
end
quest = 'Would you like to go again?';
qtitle = 'Continue?';
a = { 'Absolutely', 'No Way!'};
resp = questdlg(quest,qtitle,a{1},a{2},a{1});
if resp == a{2}
h=msgbox(sprintf('Thanks for your time on this A++ Project!'));
waitfor(h);
break
end
end
If I say yes to go again, the inputdlg should show the most recent values, not the initial defaults. HOW DO I DO THIS?!?

채택된 답변

Image Analyst
Image Analyst 2014년 12월 7일
At the bottom of the loop, redefine the defaults.
dlg_defaults = {num2str(r1), num2str(dtime), num2str(dtheta)};
  댓글 수: 2
Alexandra
Alexandra 2014년 12월 8일
Thank you! Do you know also how to get my IF statement to work depending on the answer to the question dialog? It's giving me an error that matrix dimensions don't agree on that first line of the IF statement.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by