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

8 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Aug. 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 Kommentare
Walter Roberson
Walter Roberson am 7 Aug. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by