필터 지우기
필터 지우기

how to assign variables to user inputs

조회 수: 2 (최근 30일)
Jonathan Bird
Jonathan Bird 2018년 2월 18일
답변: Star Strider 2018년 2월 18일
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,:)

답변 (1개)

Star Strider
Star Strider 2018년 2월 18일
‘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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by