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
2014-12-7
At the bottom of the loop, redefine the defaults.
dlg_defaults = {num2str(r1), num2str(dtime), num2str(dtheta)};
2 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!