matrix summation inside loop

1 回表示 (過去 30 日間)
Anindita Deka
Anindita Deka 2019 年 12 月 3 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 3 日
Hello Friends,
I need to solve this " F=(cos(q1)+cos(q2))*i '', where summation is over i from 1 to 100 and q1 and q2 are square matrices. Please help me out to solve this. I will be highly grateful.

回答 (2 件)

Andrey Kiselnikov
Andrey Kiselnikov 2019 年 12 月 3 日
編集済み: Andrey Kiselnikov 2019 年 12 月 3 日
This equation can be solved without any loops, but as you asked this code meets your requirement:
q1 = [1 2 3; 4 5 6; 7 8 9 ];
q2 = [10 11 12; 13 14 15; 7 8 9 ];
S = cos(q1)+cos(q2);
F = 0;
for i = 1:100
F = F+S*i;
end
  2 件のコメント
Anindita Deka
Anindita Deka 2019 年 12 月 3 日
thank you
Andrey Kiselnikov
Andrey Kiselnikov 2019 年 12 月 3 日
If it was helpful, please mark it as accepted. Thanks.

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


KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 3 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 3 日
#Without Loop Recomended
syms i
F_result=symsum((cos(q1)+cos(q2))*i,i,1,100)
More detail, please check here
কল্যাণ :)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by