Adding String to end of an Matrix

1 visualización (últimos 30 días)
Parker
Parker el 30 de Nov. de 2023
Respondida: Ive J el 30 de Nov. de 2023
I simply want to add a string to a matrix without combining them
for instance:
word = "";
wordlist = [];
for n = [1:3]
word = input("Word: ","s");
wordlist = [wordlist,word];
end
if the three inputs are "first", "second", "third", would make wordlist = 'firstsecondthird'.
How do I get worldlist to be ['first', 'second', 'third']?

Respuesta aceptada

Ive J
Ive J el 30 de Nov. de 2023
wordlist = strings(3, 1);
for n = 1:3
wordlist(n) = input("Word: ","s");
end

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by