'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

Thanks, it works
Interesting this one doesn't have loop either?
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.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2019년 1월 18일

댓글:

2019년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by