Save vales in Harry in a for loop

1 回表示 (過去 30 日間)
Elisbeth Brandner
Elisbeth Brandner 2021 年 8 月 2 日
コメント済み: darova 2021 年 8 月 2 日
my problem is that i do not know how to store the calculated values from my for loop:
here are examples from my tries:
First:
>>
Ri_A=0;
for i=1:15
Ri_A(i)=Ri_A+(numbA_IntStat(i)./(E_i.*cos(numbGrad(i)).*ds));
end
% Unable to perform assignment because the left and right sides have a different number of
% elements.
Second:
Ri_A=0;
for i=1:15
Ri_A=Ri_A+(numbA_IntStat(i)./(E_i.*cos(numbGrad(i)).*ds));
Ri_A()=Ri_A(i);
end
%Error Message:
% Ri_A()=Ri_A(i);
% ↑
% Error: An indexing expression on the left side of an assignment must have at least one
% subscript.

回答 (1 件)

David Hill
David Hill 2021 年 8 月 2 日
No loop needed.
Ri_A=numbA_IntStat./(E_i.*cos(numbGrad).*ds);%assuming all the same sized variables
  1 件のコメント
darova
darova 2021 年 8 月 2 日
I think it could work

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by