Calling multiple outputs from a function in a loop
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!