新手小白
建了 c.m文件
里面写了
function J = c(X,y,theta)
m=size(X,1);
predictions=X*theta;
sqrErrors = (predictions-y).^2;
J=1/(2*m)*sum(sqrErrors);
然后 调用为
>> cd E:\octaveworkplace %path
>> x = [1 1;1 2;1 3]
x =
1 1
1 2
1 3
>> y=[1;2;3]
y =
1
2
3
>> theta=[0;1]
theta =
0
1
>> j = c(x,y,theta)
parse error near line 1 of file E:\octaveworkplace\c.m
syntax error
>>> {\rtf1\ansi\ansicpg936\deff0\nouicompat\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fcharset134 \'cb\'ce\'cc\'e5;
}}
^
>>
不知道 咋改了