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

1 vue (au cours des 30 derniers jours)
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?!?

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by