MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

0

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));
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 件のコメント

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

サインイン to comment.

0 件の回答


Translated by