What is wrong with this code (SCILAB)?

99 Views Asked by At

i wrote this on scilab:

function q=arrow(x0,y0,z0,a0,r,s) j=1;

while norm(gradJ(x0,y0,z0) - gradF(x0,y0,z0))>10^-10
    a0 = max(0, a0 + s*f(x0,y0,z0));
    [x0;y0;z0] = [x0;y0;z0] - r*(gradJ(x0,y0,z0)+a0*gradF(x0,y0,z0));
    j=j+1;
end

gradJ=[x0;y0;z0];
q=[gradJ;j];
endfunction

i got this error message: "Instruction left hand side: waiting for a dot or a left parenthesis."

i dont understand. Someone see any error?

1

There are 1 best solutions below

0
On

Try putting the "j=1" statement on a new line (actually I think you have - it's just the formatting here that makes it look like it's on the same line as the "function" command) and putting a semicolon after "endfunction":

function q=arrow(x0,y0,z0,a0,r,s)
 j=1;

 while norm(gradJ(x0,y0,z0) - gradF(x0,y0,z0))>10^-10
     a0 = max(0, a0 + s*f(x0,y0,z0));
     [x0;y0;z0] = [x0;y0;z0] - r*(gradJ(x0,y0,z0)+a0*gradF(x0,y0,z0));
     j=j+1;
 end

 gradJ=[x0;y0;z0];
 q=[gradJ;j];
 endfunction;