I am trying to solve the above objective function for theta using quasi newton method. But I am getting the following error. Can somebody please help me fix this error?
Following is my matlab code:
Code for defining objective function:
function f = objfun(x_t,c_n,theta) t=0:length(x_t)-1; L=length(t); n=0:length(c_n)-1; N=length(n); for i=1:L for j=1:N f=@(theta) sum((x_t(i)-sum(c_n(j).*exp(-((t(i)-n(j)*a)^2/theta^2))))^2)endend end
Code for calling objective function:
a = 1; x_t=rand(32,1); c_n=rand(32,1);f = @(theta) objfun(x_t,c_n,theta)theta0 = 20;options = optimoptions('fminunc','Algorithm','quasi-newton');[theta, thetaval] = fminunc(f,theta0,options)
%
Best Answer