Error: Unexpected MATLAB expression.

I simply do not understand how there is an error here,
>> f = symsum((1/(2*n-1))*sin((2*n-1)2*x), n, 1, 5)
Error: Unexpected MATLAB expression.
To clarify the arrow is pointing at the "2" next to "x".
Edit: I have defined x and n as symbolic, but the error still occurs.

 Respuesta aceptada

Birdman
Birdman el 26 de Oct. de 2017
Editada: Birdman el 26 de Oct. de 2017
You have not defined n and x as symbolic.
syms n x
f = symsum((1/(2*n-1))*sin((2*n-1)*2*x), n, 1, 5)

3 comentarios

Ian Bathgate
Ian Bathgate el 26 de Oct. de 2017
The error still occurs
Birdman
Birdman el 26 de Oct. de 2017
I edited the equation. There was a operator missing. Now check the answer.
Ian Bathgate
Ian Bathgate el 26 de Oct. de 2017
Thank you so much, I sat there looking at it for nearly 20 minutes. thanks.

Iniciar sesión para comentar.

Más respuestas (1)

Jan
Jan el 26 de Oct. de 2017
Editada: Jan el 26 de Oct. de 2017
"(2*n-1)2*x" is no valid Matlab expression, because the operator after ")" is missing. I guess:
f = symsum((1/(2*n-1))*sin((2*n-1) * 2*x), n, 1, 5)
% ^ inserted

2 comentarios

Birdman
Birdman el 26 de Oct. de 2017
Exactly
Jan
Jan el 27 de Oct. de 2017
:-) This was a duplicate answer given in the same minute.

Iniciar sesión para comentar.

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 26 de Oct. de 2017

Comentada:

Jan
el 27 de Oct. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by