I am new to matlab.
I am going to find the minimun value give the function: x(1)^2 - 2*x(1)*x(2) + 6*x(1) + x(2)^2 - 6*x(2)
I am trying to write the matlab code without using the anonymous function, but I am stuck here now.
Here is my code:
function minFun()
res = fminsearch(@f2, [0,0]);
function out = f2([x(1) x(2)])
out = x(1)^2 - 2*x(1)*x(2) + 6*x(1) + x(2)^2 - 6*x(2);
end
end
But it mentions that here is syntax error in function out = f2([x(1) x(2)]). How should I fix that?