for loop append variable

20 次查看(过去 30 天)
il147
il147 2022-2-18
评论: il147 2022-2-22
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
Stephen23 2022-2-18
That is why I showed you this approach:
{list.name}.'
Much simpler than a loop.
il147
il147 2022-2-18
It works!!!! Thanks for your help!!

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2022-2-18
编辑:KSSV 2022-2-18
You can make it a cell array.
leng=length(list)
nl = cell(leng,1) ;
for i=1:leng
nl{i}=list(i).name
end
You may access n1{1}.........n1{10}
  3 个评论
KSSV
KSSV 2022-2-18
You can do the same as shown above. Store them into a cell array.
il147
il147 2022-2-22
Do you have any idea to make it matrix form not cell array?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by