Collecting the outputs of a function within a for loop
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nikolaos Zafirakis
el 17 de Abr. de 2019
Comentada: Nikolaos Zafirakis
el 17 de Abr. de 2019
I’ve got a function within a for loop and I want to collect the output variables of the function. Currently, the outputs A, B, C, D give only the last number in the series.
time = 100;
for i=1:length(time)
[A,B,C,D] = Name(a,b,c,d,time);
end
0 comentarios
Respuestas (1)
madhan ravi
el 17 de Abr. de 2019
Editada: madhan ravi
el 17 de Abr. de 2019
time = 100;
[A,B,C,D]=deal(cell(100,1)); % if the outputs are scalars then use zeros() instead of cell
for ii=1:time
[A{ii},B{ii},C{ii},D{ii}] = Name(a,b,c,d,time);
end
3 comentarios
madhan ravi
el 17 de Abr. de 2019
It’a not working doesn’t give any useful information, what error message are you getting?
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!