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 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