for loop append variable
显示 更早的评论
i'd like to append variable n0 to n1
but this code made just last variable
Thanks!
leng=length(list)
n0=[]
for i=1:leng
nl=list(i).name
end
6 个评论
Stephen23
2022-2-18
No need to use a loop:
{list.name} % to place into a cell array
[list.name] % to concatenate together
il147
2022-2-18
vertcat(list.name) % concatenate elements
[list.name].' % concatenate elements
{list.name}.' % place elements into a cell array
il147
2022-2-18
Stephen23
2022-2-18
That is why I showed you this approach:
{list.name}.'
Much simpler than a loop.
il147
2022-2-18
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!