Calling multiple outputs from a function in a loop
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to call multiple outputs from a function in a for loop. The code I tried initially is below
for i =1:tsteps
[tnewfin1 (:,i+1),crfin1(1,i)] = newtstep (tnewfin1 (:,i));
end
However I constantly received the error "Invalid use of operator".
I changed it to the following,
for i =1:tsteps
[tnewfin,crfin] = newtstep (tnewfin1 (:,i));
tnewfin1 (:,i+1) = tnewfin
crfin1(1,i) = crfin
end
which worked, despite not really changing what is happening.
I thought the first one would work because initially, when I just wanted one output from the function, the following code ran succesfully
for i =1:tsteps
tnewfin1 (:,i+1) = newtstep (tnewfin1 (:,i));
end
Why would it work to call one output but not two, or why is the first scenario an "invalid use of operator"?
1 comentario
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!