代码:
function objfun = xianyan
load train_hi.mat;
chi=train_hi;
U_n=cell(1,100);
I=cell(1,100);
syms x;
syms y;
syms z;
syms h;
a=0;
for i=1:100
L=length(chi{1,i});
%U_n
U_n{1,i}=ones(L);
for j=1:L
for k=j:L
U_n{1,i}(j,k)=j;
U_n{1,i}(k,j)=j;
end
I{1,i}(j,1)=exp(z*j)-1;
end
%N
a=a+chi{1,i}(end,1);
end
b=[];
c=[];
for r=1:100
b(r,1)=double(log(yI{1,r}(I{1,r})'+hU_n{1,r}))
c(r,1)=double((chi{1,r}(:,1)-xI{1,r}(:,1))'/(yI{1,r}(:,1)(I{1,r}(:,1))'+hU_n{1,r})(chi{1,r}(:,1)-x*I{1,r}(:,1)));
end
fun=log(2*pi)*a+sum(b)+sum(c);
objfun=@(x)fun(x,y,z,h);
end
报错:
[x,fval]=fminsearch(xianyan,[0.1,0.1,0.1],optimset('maxfunevals',1e10000000))
错误使用 symengine
DOUBLE cannot convert the input expression into a double array.
出错 sym/double (line 613)
Xstr = mupadmex('symobj::double', S.s, 0);
出错 xianyan (line 29)
b(r,1)=double(log(yI{1,r}(I{1,r})'+h*U_n{1,r}))
我想请问一下我应该如何解决这个问题
用fminsearch函数求解想(x,y,z,h)这四个参数