How can I use input values to create an array?

23 ビュー (過去 30 日間)
Nureen Hoosein
Nureen Hoosein 2015 年 3 月 31 日
回答済み: Shagun Sharma 2020 年 1 月 21 日
How would I get the xii input values to form an array called xi in the following code?
for ii = 1:5 xii = input('Enter value or enter 100 to stop: '); if xii == 100 break; end end
xi=[xii];

回答 (3 件)

Ganesh Gaonkar
Ganesh Gaonkar 2015 年 3 月 31 日
You should be able to use 'input' function as shown here: http://in.mathworks.com/help/matlab/ref/input.html

Konstantinos Sofos
Konstantinos Sofos 2015 年 3 月 31 日
xi = []; % Initialize array/vector
for i=1:5
xii = input('Enter value or enter 100 to stop: ');
if xii==100
break
else
xi(end+1)=xii;
end
end

Shagun Sharma
Shagun Sharma 2020 年 1 月 21 日
%For making an array from input values follow the below sequence (customise as per your requirenments):
%Firstly initialize an array
xi = [];
for i=1:5
xii = input('Enter value or enter 100 to stop: ');
if (xii==100)
break;
else
xi(i)=xii;
end
end

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by