Clear Filters
Clear Filters

for loop append variable

6 views (last 30 days)
il147
il147 on 18 Feb 2022
Commented: il147 on 22 Feb 2022
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 Comments
Stephen23
Stephen23 on 18 Feb 2022
That is why I showed you this approach:
{list.name}.'
Much simpler than a loop.
il147
il147 on 18 Feb 2022
It works!!!! Thanks for your help!!

Sign in to comment.

Accepted Answer

KSSV
KSSV on 18 Feb 2022
Edited: KSSV on 18 Feb 2022
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 Comments
KSSV
KSSV on 18 Feb 2022
You can do the same as shown above. Store them into a cell array.
il147
il147 on 22 Feb 2022
Do you have any idea to make it matrix form not cell array?

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!