谁能告诉我为什么我在 GNU Octave 中遇到这个错误
Can anyone please tell why I'm getting this error in GNU Octave
我不知道为什么会显示此错误。我尝试用其他名称更改 temp1,但它是一样的。
>> for i = [1:10000]
temp0 = theta0 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,1)
temp1 = theta1 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,2)
parse error:
syntax error
>>> temp1 = theta1 - (a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,2)
^
您在表达式中缺少右括号“)”。可能是这样
temp0 = theta0 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,1))
temp1 = theta1 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,2))
你有一组不平衡的括号。观看:
temp0 = theta0 -
(
(a / m) *
(
(
X(i,1) * theta0 + X(i,2) * theta1
)
- Y(i)
)
* X(i,1)
% <-- The bracket at this indentation level has not been closed.
Octave 抱怨是因为您没有关闭那个括号,因此您试图在完成前一个语句之前分配给第二个变量。
我不知道为什么会显示此错误。我尝试用其他名称更改 temp1,但它是一样的。
>> for i = [1:10000]
temp0 = theta0 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,1)
temp1 = theta1 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,2)
parse error:
syntax error
>>> temp1 = theta1 - (a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,2)
^
您在表达式中缺少右括号“)”。可能是这样
temp0 = theta0 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,1))
temp1 = theta1 - ((a/m)*((X(i,1)*theta0 + X(i,2)*theta1) - Y(i))*X(i,2))
你有一组不平衡的括号。观看:
temp0 = theta0 -
(
(a / m) *
(
(
X(i,1) * theta0 + X(i,2) * theta1
)
- Y(i)
)
* X(i,1)
% <-- The bracket at this indentation level has not been closed.
Octave 抱怨是因为您没有关闭那个括号,因此您试图在完成前一个语句之前分配给第二个变量。