I got this this error when I run the program (Error while parsing expression)

8 visualizaciones (últimos 30 días)
I am using a function with different inputs but I got this error
Error while parsing expression: (((u(1))–(cax*(u(2))*(u(2)))–(jr*(u(5))*(u(3)))–((iz-iy)*(u(3))*(u(4))))/(ix)) in 'Final_Modelling_Sub/Quadcopter System Dynamics/Translational & Rotational Dynamics/Phidd Equation1' token "" was found, whereas ")" was expected

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Ag. de 2021
(((u(1))(cax*(u(2))*(u(2)))(jr*(u(5))*(u(3)))((iz-iy)*(u(3))*(u(4))))/(ix))
That code is using unicode U+2013 "EN DASH" instead of U+002D "hyphen-minus" which is the - character
  4 comentarios
Walter Roberson
Walter Roberson el 7 de Ag. de 2021
S = '(((cos(u(2))*cos(u(4))*sin(u(3)))+(sin(u(2))*(sin(u(4)))*(u(1)))-(cdx*(u(5))))/(m)'
S = '(((cos(u(2))*cos(u(4))*sin(u(3)))+(sin(u(2))*(sin(u(4)))*(u(1)))-(cdx*(u(5))))/(m)'
% 123  4 5 43 4 5 43 4 5 432 3 4 5 43 4 5 6 543 4 5 432 3 4 5 4321 2 1
sum(S == '(')
ans = 21
sum(S == ')')
ans = 20
21 open brackets, 20 closing brackets.
The numbers above are the number of bracket levels in effect "after" the character above has been executed. You can see that you get back to 1, but you should be getting back to 0 instead.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by