One-dimensional array of variable length
16 ビュー (過去 30 日間)
古いコメントを表示
I need to create a one-dimensional string array of variable length that I can add elements to as needed. I don't know how long it will need to be, as that will be determined by the rest of the program I'm writing, so ideally it will begin with no elements and I can then add as my program loops over other data.
Is there any easy way to do this? Let me know, thanks!
- John
0 件のコメント
回答 (3 件)
Laura Proctor
2011 年 4 月 12 日
Any variable can change length throughout the code. You can run each line below and see what it does to the variable s1.
s1 = 'Peter'
s1 = [ s1 ' Parker']
s1 = 'Spider-man'
0 件のコメント
Andrei Bobrov
2011 年 4 月 13 日
better use of cell array
strcll = [];
for j = ...
...
result(j)
...
strcll = [ strcll; {result(j)}];
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!