'for loop' summation containing symbolic variable

I tried to carry out a summation in 'for loop' which has symbolic variable in it. but it is showing some errors. I am attaching my script file. Please tell me where I am getting wrong.

 採用された回答

Stephan
Stephan 2019 年 1 月 18 日
編集済み: Stephan 2019 年 1 月 18 日

0 投票

Hi,
some bugs - try:
clear
syms n
Cs=1000;
k=1e8;
D=1e-3;
t=linspace(1e-7,1e-5);
w2n=(n.^2)*pi^2*D/4;
g=((1-(-1).^n)./(n.^2)).*(exp(-w2n.*t)+(k.*(1-(1+w2n.*t).*exp(-w2n.*t)))./(w2n+k.*(1-exp(-w2n.*t))));
sum1 = symsum(g,n,1,250);
plot(t,(1+Cs*(1-(sum1.*4/pi^2))))
Best regards
Stephan

3 件のコメント

Aniket Masaye
Aniket Masaye 2019 年 1 月 18 日
Thanks, it works
madhan ravi
madhan ravi 2019 年 1 月 18 日
Interesting this one doesn't have loop either?
Aniket Masaye
Aniket Masaye 2019 年 1 月 18 日
he edited this file. Before this code had loop.

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

その他の回答 (1 件)

madhan ravi
madhan ravi 2019 年 1 月 18 日

0 投票

Use symsum() straight away instead of loop.

1 件のコメント

Aniket Masaye
Aniket Masaye 2019 年 1 月 18 日
Actually I want to do it in for loop

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

カテゴリ

ヘルプ センター および 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