Borrar filtros
Borrar filtros

for loop append variable

6 visualizaciones (últimos 30 días)
il147
il147 el 18 de Feb. de 2022
Comentada: il147 el 22 de Feb. de 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 comentarios
Stephen23
Stephen23 el 18 de Feb. de 2022
That is why I showed you this approach:
{list.name}.'
Much simpler than a loop.
il147
il147 el 18 de Feb. de 2022
It works!!!! Thanks for your help!!

Iniciar sesión para comentar.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by