MATLAB Answers


Calling multiple outputs from a function in a loop

Samuel Newall さんによって質問されました 2018 年 12 月 15 日
最新アクティビティ madhan ravi
さんによって コメントされました 2018 年 12 月 15 日
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));
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
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));
Why would it work to call one output but not two, or why is the first scenario an "invalid use of operator"?

  1 件のコメント

madhan ravi
2018 年 12 月 15 日
please upload the function and the datas to run your code

サインイン to comment.

0 件の回答

Translated by