How to assign input given by user via inpuutdlg command to variables
조회 수: 1 (최근 30일)
이전 댓글 표시
I have used inputdlg command to get multiple user inputs. I want to assign these values to variables that is have defined.
댓글 수: 0
채택된 답변
Stephen23
2019년 9월 9일
편집: Stephen23
2019년 9월 9일
Just use indexing:
out = inputdlg(...);
somevar = out{1};
othervar = out{2};
...
댓글 수: 2
Stephen23
2019년 9월 9일
편집: Stephen23
2019년 9월 9일
@Sachin Dighe: inputdlg returns character vectors in a cell array, not numerics. It is not clear to me what you expect to get by using + on some cell arrays.
If you want numeric values, then you will need to convert the character vectors to numeric, e.g. using str2double or sscanf or the like:
>> out = inputdlg({'A','B'});
>> A = str2double(out(1));
>> B = str2double(out(2));
>> A+B
ans =
7.3
Note that this issue is unrelated to your original question and my answer, so it is unclear why you have unaccepted my answer (which correctly answered your question).
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!