How do you create an array from input statements?
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Voss
2021-12-28
A = [];
while true
new = input('Enter a number: ');
if isempty(new)
break
end
A(end+1) = new;
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!