Filter löschen
Filter löschen

how to assign variables to user inputs

2 Ansichten (letzte 30 Tage)
Jonathan Bird
Jonathan Bird am 18 Feb. 2018
Beantwortet: Star Strider am 18 Feb. 2018
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,:)

Antworten (1)

Star Strider
Star Strider am 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.

Community Treasure Hunt

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

Start Hunting!

Translated by