loop with easy underfunction
Mostrar comentarios más antiguos
function tretti
for k=1:3
F=results(k)
end
function h=results(k)
A ={k*2};
A1(k)= A
h=A1
%output: F=[] [] [6]
%what i want: F=[2] [4] [6] //cell array
1 comentario
ErikJ
el 7 de Nov. de 2017
Respuestas (1)
Rik
el 7 de Nov. de 2017
Because you are overwriting it every iteration.
function F=tretti
for k=1:3
F{k}=results(k);
end
function h=results(k)
A ={k*2};
A1(k)= A;
h=A1;
You should look into cellfun, it may be really useful for what you are trying to do.
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!