필터 지우기
필터 지우기

how to ask users to input different number of values at each time according to a specific condition

조회 수: 2 (최근 30일)
There is a code that presented in the following, that I want to ask users to input different number of values according to a specific condition (i.e. rock_code). Since size(rock_code,1) equals different values each time (=1,2,3,4,5...), so the user needs to enter the value of the corresponding quantity
a=zeros(1,size(rock_code,1));
for i=1:size(rock_code,1)
string=['Enter the vecter numbers of ' int2str(i) ':'];
a(i)=input(string);
end
So, is it possible to create a interface to ask user to input different quantity values at each time according to the specific condition (i.e. rock_code), like using inputdlg function? Could you please give me some solutions as I do not know how to do that?

채택된 답변

Walter Roberson
Walter Roberson 2021년 7월 7일
편집: Walter Roberson 2021년 7월 7일
strings = compose("a(%d)", 1:size(rock_code,1));
data_str = inputdlg(strings);
a = str2double(data_str);
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 7월 8일
I tested the code. It does permit entering multiple values. For example
rock_code = randi(9,3,1);
and then run the code, then it will prompt for three values

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by