how to assign variables to user inputs
1 view (last 30 days)
Show older comments
I'm asking the user to input 6 values between 1 and 59, I want to assign variables to each input so they can be compared etc. I think the final line of code may help in doing this but I don't understand what it does?
prompt = {'Enter your first integer between 1 and 59', 'Enter your second integer between 1 and 59', 'Enter your third integer between 1 and 59', 'Enter your fourth integer between 1 and 59', 'Enter your fifth integer between 1 and 59', 'Enter your sixth integer between 1 and 59' };
dlg_title = 'User inputs';
num_lines = 1;
answer =inputdlg(prompt,dlg_title,num_lines);
dlg_answer{1}(1,:)
0 Comments
Answers (1)
Star Strider
on 18 Feb 2018
‘I think the final line of code may help in doing this but I don't understand what it does?’
The inputdlg function returns a cell array of character variables. If you want numbers from it, you may need to use the str2double to produce double-precision floating-point numbers.
0 Comments
See Also
Categories
Find more on Logical 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!