How do you create an array from input statements?

조회 수: 4 (최근 30일)
Xena Erzi
Xena Erzi 2021년 11월 14일
답변: Voss 2021년 12월 28일
Hello, community!
I was wondering if there is a way of storing (nummerical) inputs into a defining array.
I do not mean the A = [value1 value2 ... valuen], it's more of taking from a loop
input("Enter a number: ") and then storing all the inputs you give to a certain point in a variable.
I hope this is formulated clear enough, if not, please ask!
Kind regards,
Xena

답변 (1개)

Voss
Voss 2021년 12월 28일
A = [];
while true
new = input('Enter a number: ');
if isempty(new)
break
end
A(end+1) = new;
end

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by