How to set Reallyl Basic iterative sum

1 回表示 (過去 30 日間)
Niklas Kurz
Niklas Kurz 2021 年 1 月 15 日
編集済み: KSSV 2021 年 1 月 15 日
I want to sum up all n*sin(n*x)-terms. I've found that
f = n*sin(n*x)
for n = 1:10
f(n+1) = n*sin(n*x);
end
sum(f)
works. However, in my view it's not that elegant. In other words, how to implement without using 'sum'?

採用された回答

KSSV
KSSV 2021 年 1 月 15 日
編集済み: KSSV 2021 年 1 月 15 日
% f = n*sin(n*x) ;
thesum = 0 ;
for n = 1:10
thesum = thesum+n*sin(n*x);
end

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by