Effacer les filtres
Effacer les filtres

How do you create an array from input statements?

2 vues (au cours des 30 derniers jours)
Xena Erzi
Xena Erzi le 14 Nov 2021
Réponse apportée : Voss le 28 Déc 2021
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

Réponses (1)

Voss
Voss le 28 Déc 2021
A = [];
while true
new = input('Enter a number: ');
if isempty(new)
break
end
A(end+1) = new;
end

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by