Hello, i am trying to find the minimum of a multivariable function (the number of variables may vary also but there is a pattern to construct the function) the code i am running is the following:
function F = jac(x)n=input('n=');x0=random('unid',90,1,n,1);x0=pi./x0;E=input('E=');h=3;F=0;for i=1:n D= 0.5;% V=0;
% b=0;
for j=1:n if (mod(j,2)==0) D = D + cos(h*x(j)); else D = D - cos(h*x(j)); end end D=(2*E*sqrt(2)/(pi*h))*abs(D); F = F + 1/h*(D^2); h=h+2;endM=fminsearch(@(x)jac,x0);
the error i am getting is that the function x is undefined can anyone help me please? thanks in advance
Best Answer