Summation for series (symsum function), only want odd numbers

10 ビュー (過去 30 日間)
Big Meech
Big Meech 2013 年 9 月 24 日
回答済み: Nisarg Dave 2019 年 8 月 16 日
Hello All,
What I'm having trouble with is that I only want odd values n eg 1 3 5 7 9 inputted.
Is there a way I can go about this?
Code
Sums n x
Symsum(0.5+(2/pi).*((1/n).*sin(2.*pi.*n.*x)),n,1,9)

採用された回答

Youssef  Khmou
Youssef Khmou 2013 年 9 月 24 日
編集済み: Youssef Khmou 2013 年 9 月 24 日
That is Square function ,the task needs skills, you can try loop , it is possible to work :
syms x n
SUM=0;
a=1:2:9;
F=0.5+(2/pi).*((1/n).*sin(2.*pi.*n.*x));
for jj=1:length(a)-1
A=symsum(F,n,a(jj),a(jj+1));
SUM=SUM+A;
end
pretty(SUM)

その他の回答 (1 件)

Nisarg Dave
Nisarg Dave 2019 年 8 月 16 日
I would like to make a small change in the answer.
Following is the correct code ::
syms x n
SUM=0;
a=1:2:9;
F=0.5+(2/pi).*((1/n).*sin(2.*pi.*n.*x));
for jj=1:length(a)
A=symsum(F,n,a(jj),a(jj));
SUM=SUM+A;
end
pretty(SUM)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by