A'(' might be missing a closing ')' causing invalid syntax at the end of line

40 views (last 30 days)
At the den(cnt) section I am getting the " A'(' might be missing a closing ')' causing invalid syntax at the end of line " message. What am I missing here?
m1 = 1; m2 = 1;
m3 = 1; c1 = 0;
c2 = 0; k1 = 1;
k2 = 1;
w = logspace(-1,1,200);
rad2deg = 180/pi;
for cnt = 1:length(w)
s = j*w(cnt);
den(cnt) = s^2*(s^4*(m1*m2*m3) + s^3*(m2*m3*c1 + m1*m3*c1 + m1*m2*c2
+ m1*m3*c2) + s^2*(m1*m3*k1 + m1*m3*k2 + m1*m2*k2 ...
+ m2*c1*c2 + m3*c1*c2 + m1*c1*c2 + k1*m2*m3) ...
+ s*(m3*c1*k2 + m2*c2*k1 + m1*c2*k1 + m1*c1*k2 ...
+ m3*c2*k1 + m2*c1*k2) + (m1*k1*k2 + m2*k1*k2 + m3*k1*k2));
  3 Comments
Steven Lord
Steven Lord on 7 May 2023
Either you are missing a line continuation as @Voss wrote or you are missing a ) on a line of your code. Without seeing a small sample of the code that causes the error we cannot tell which of those conditions is the cause of the error.
Count your opening and closing parentheses. Start at 0, add 1 for each ( and subtract 1 for each ). If the total would ever become negative or if it does not become 0 at the end of the statement, that indicates a problem. For example, in the code above without the ellipsis:
den(cnt) = s^2*(s^4*(m1*m2*m3) + s^3*(m2*m3*c1 + m1*m3*c1 + m1*m2*c2
%0 1 0 1 2 1 2
This statement doesn't end at 0 so it has two unclosed sets of parentheses.
With the ellipsis making this all one statement:
den(cnt) = s^2*(s^4*(m1*m2*m3) + s^3*(m2*m3*c1 + m1*m3*c1 + m1*m2*c2 ...
... %0 1 0 1 2 1 2
+ m1*m3*c2) + s^2*(m1*m3*k1 + m1*m3*k2 + m1*m2*k2 ...
... % 1 2
+ m2*c1*c2 + m3*c1*c2 + m1*c1*c2 + k1*m2*m3) ...
... % 1
+ s*(m3*c1*k2 + m2*c2*k1 + m1*c2*k1 + m1*c1*k2 ...
... % 2
+ m3*c2*k1 + m2*c1*k2) + (m1*k1*k2 + m2*k1*k2 + m3*k1*k2));
% 1 2 10
all the sets of parentheses are closed.

Sign in to comment.

Accepted Answer

Voss
Voss on 12 Nov 2022
You are missing the ellipses (i.e., "...") at the end of the first line where den(cnt) is defined.
den(cnt) = s^2*(s^4*(m1*m2*m3) + s^3*(m2*m3*c1 + m1*m3*c1 + m1*m2*c2 ...
% ^^^
% these are missing

More Answers (0)

Community Treasure Hunt

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

Start Hunting!