How can i keep asking them the same inputdlg based on how many they want to input?

3 ビュー (過去 30 日間)
goodwin membreve
goodwin membreve 2020 年 10 月 28 日
コメント済み: Jakob 2020 年 10 月 28 日
count='How many values do you want?';
vcount=inputdlg(count);
eqprompt='Enter Values';
value(vcount)=inputdlg(eqprompt);
eqprompt='Enter Values';
value(vcount)=inputdlg(eqprompt);
How to repeat the "Enter Value' dialog box until the count is equal to the number of times it repeat?

採用された回答

Jakob
Jakob 2020 年 10 月 28 日
count='How many values do you want?';
vcount=inputdlg(count);
vcount = str2double(vcount{1});
eqprompt='Enter Values';
value = [];
for i = 1 : vcount
answer =inputdlg(eqprompt);
try value(1, i)= str2double(answer{1}); %this is for empty input. In case you changed your mind with the number of inputs
catch
break;
end
end
  2 件のコメント
goodwin membreve
goodwin membreve 2020 年 10 月 28 日
THANK YOU!! i have another question, what if i want the user to enter polynomial equations and only store the coefficient of each term?
Jakob
Jakob 2020 年 10 月 28 日
You could try it with
split('4x^4 +4x^3 -2x^2', ["x^" , " "])
but I'm not sure, how to handle this :(

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by