Adding String to end of an Matrix

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']?

 Accepted Answer

wordlist = strings(3, 1);
for n = 1:3
wordlist(n) = input("Word: ","s");
end

More Answers (0)

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Products

Release

R2023a

Asked:

on 30 Nov 2023

Answered:

on 30 Nov 2023

Community Treasure Hunt

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

Start Hunting!