Adding String to end of an Matrix

조회 수: 2 (최근 30일)
Parker
Parker 2023년 11월 30일
답변: Ive J 2023년 11월 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에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by