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

2 views (last 30 days)
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?!?

Accepted Answer

Image Analyst
Image Analyst on 7 Dec 2014
At the bottom of the loop, redefine the defaults.
dlg_defaults = {num2str(r1), num2str(dtime), num2str(dtheta)};
  2 Comments
Alexandra
Alexandra on 8 Dec 2014
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!