How do I index correctly from my questdlg command to my if statement? I am trying to direct the user into different code based on their questdlg responses. I have many more in this code but I am stuck HELP!
Show older comments
quest = 'What type of rod are you using?';
qtitle = 'Axial load problem';
a = {'Circular', 'Rectangular'};
resp=questdlg(quest,qtitle,a{1},a{2},a{1});
h=msgbox(sprintf('You selected %s',resp));
respa = str2num('resp');
waitfor(h);
if respa == 1
% create a user prompted space to calculate the axial load problem for a
% circular rod
dlg_prompts = {'Axial load','Radius','Inner Radius',...
'Length','Young''s Modulus E'};
dlg_title = 'Axial Load';
dlg_defaults = {'0','0','0','0','0'};
opts.Resize = 'on'; % a structure
dlg_ans = inputdlg(dlg_prompts,dlg_title,1,dlg_defaults,opts);
P = str2double(dlg_ans(1));
r = str2double(dlg_ans(2));
ir = str2double(dlg_ans(3));
L = str2double(dlg_ans(4));
E = str2double(dlg_ans(5));
else
% create a user prompted space to calculate the axial load problem for a
% rectangular rod
dlg_prompts = {'Axial load','Base','Height','Inner Base','Inner Height',...
'Length','Young''s Modulus E'};
dlg_title = 'Axial Load';
dlg_defaults = {'0','0','0','0','0','0','0'};
opts.Resize = 'on'; % a structure
dlg_ans = inputdlg(dlg_prompts,dlg_title,1,dlg_defaults,opts);
P = str2double(dlg_ans(1));
b = str2double(dlg_ans(2));
h = str2double(dlg_ans(3));
ib = str2double(dlg_ans(4));
ih = str2double(dlg_ans(5));
L = str2double(dlg_ans(6));
E = str2double(dlg_ans(7));
end%if
Accepted Answer
More Answers (0)
Categories
Find more on App Building 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!