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

 Respuesta aceptada

Stephan
Stephan el 18 de En. de 2019
Editada: Stephan el 18 de En. de 2019

0 votos

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 comentarios

Aniket Masaye
Aniket Masaye el 18 de En. de 2019
Thanks, it works
madhan ravi
madhan ravi el 18 de En. de 2019
Interesting this one doesn't have loop either?
Aniket Masaye
Aniket Masaye el 18 de En. de 2019
he edited this file. Before this code had loop.

Iniciar sesión para comentar.

Más respuestas (1)

madhan ravi
madhan ravi el 18 de En. de 2019

0 votos

Use symsum() straight away instead of loop.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de En. de 2019

Comentada:

el 18 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by