How to set Reallyl Basic iterative sum

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by