What is the syntax error "Error: Unbalanced or unexpected parenthesis or bracket."?

What is the syntax error "Error: Unbalanced or unexpected parenthesis or bracket."?

以下代码产生错误

n=4; 
p=3; 
x =-(pi./2); 
y=-(pi./2);
z=-(pi./2); 

%Now, define the matrix v_k  
v_k = [sin(x).*sin(y).*sin(z), ...
    1-(1-cos(x))(sin(y).^2.*sin(z).^2), ...
    -(1-cos(x))(sin(y).^2.*sin(z).*cos(z)), ...
    -(1-cos(x))(sin(y).*sin(z).*cos(y)); ...
    sin(x).*sin(y).*cos(z), ...
    -(1-cos(x))(sin(y).^2.*sin(z).*cos(z)), ...
    1-(1-cos(x))(sin(y).^2.*cos(z).^2), ...
    -(1-cos(x))(sin(y).*cos(y).*cos(z)); ...
    sin(x).*cos(y), ...
    -(1-cos(x))(sin(y).*sin(z).*cos(y)), ...
    -(1-cos(x))(sin(y).*cos(y).*cos(z)), ...
    1-(1-cos(x))(cos(y).^2); ...
    cos(x), ...
    -sin(x).*sin((y).*sin(z),...
    -sin(x).*sin(y).*cos(z),...
    -sin(x).*cos(y)];

显示的错误是:

Error: File: test.m Line: 9 Column: 17 Unbalanced or unexpected parenthesis or bracket.

或者,如果 运行 来自命令 window

v_k = [sin(x).*sin(y).*sin(z), ...
    1-(1-cos(x))(sin(y).^2.*sin(z).^2)]
     1-(1-cos(x))(sin(y).^2.*sin(z).^2)]
                 ↑
Error: Unbalanced or unexpected parenthesis or bracket.

看起来你缺少一个右括号,至少在倒数第二行你有 .*sin((y).*sin(z), 并且在你的 [=12= 之间缺少 * (或另一个运算符) ] 在几行。在 MATLAB 中 (A)(B) 不是 A*B.