MATLAB 意外的括号错误

MATLAB Unexpected Parentheses error

我试图在 MATLAB 中输入这个表达式,但出现错误:

Error: Unbalanced or unexpected parenthesis or bracket.

y = (exp(t./10)*sin(t.))./(t.^2 + 1)

我是 MATLAB 的新手,不太确定那里出了什么问题。

删除sin(t.)中多余的点... sin(t)。此外,如果您希望它是元素明智的,那么在 * 运算符之前添加一个点是个好主意,就像您的其余操作一样:

y = (exp(t./10).*sin(t))./(t.^2 + 1)

证明这是可行的:

>> t = 0:10;
>> y = (exp(t./10).*sin(t))./(t.^2 + 1)

y =

  Columns 1 through 7

         0    0.4650    0.2221    0.0190   -0.0664   -0.0608   -0.0138

  Columns 8 through 11

    0.0265    0.0339    0.0124   -0.0146