Adding String to end of an Matrix

1 次查看(过去 30 天)
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']?

采纳的回答

Ive J
Ive J 2023-11-30
wordlist = strings(3, 1);
for n = 1:3
wordlist(n) = input("Word: ","s");
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by