How can I use input values to create an array?

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];

Antworten (3)

Konstantinos Sofos
Konstantinos Sofos am 31 Mär. 2015

0 Stimmen

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 am 21 Jan. 2020

0 Stimmen

%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

Kategorien

Mehr zu Beamforming and Direction of Arrival Estimation finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 31 Mär. 2015

Beantwortet:

am 21 Jan. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by