FMINCON only accepts inputs of data type double.
我的程序如下:主程序:
n=input('enter a value for n\n=')
a1=0.2875;
kmax=1.33;
x0=zeros(n,1);
A=[];
b=[];
Aeq=data_preprocess(a1,kmax);
beq=xlsread('F:\Program Files\work\DATA','sheet1','H4:H33');
lb=zeros(n,1);
ub=[];
= fmincon(@myobjfun,x0,A,b,@data_preprocess(a1,kmax),beq,lb,ub);
子函数:myobjfun
function f = myobjfun(x)
f = sum(diff(x).^2);
子函数data_preprocess
function Aeq=data_preprocess(a1,kmax)
%从EXCEL表格中读取TBP(END T)数据,T(K)
TBP=xlsread('F:\Program Files\work\DATA','sheet1','G3:G33') %待完善:sheet1、以及G3:G33如何用n表示
%计算标准温度\theta
o1=TBP(1);
o2=TBP(31);
T=(TBP-o1)/(o2-o1)
%计算速率常数k
o3=1/a1
o4=T.^o3
k=o4.*kmax
%计算a(i,1)和a(i,2)
for i=1:30
m1=k(i)-k(i+1);
m2=30*31*a1/kmax^a1;
m3=k(i+1)^(a1+1)/(a1+1);
m4=k(i+1)^(a1+1)/a1;
m5=k(i)^(a1+1)/(a1+1);
m6=k(i+1)*k(i)^a1/a1;
m7=k(i)*k(i+1)^a1/a1;
m8=k(i)^(a1+1)/a1;
a(i,1)=(1/m1)*m2*((m3-m4)-(m5-m6));
a(i,2)=(1/(-m1))*m2*((m3-m7)-(m5-m8));
end
for i=1:30
Aeq(i,i)=a(i,1);
Aeq(i,i+1)=a(i,2);
end
disp(Aeq);
然后运行就出现了如题的报错信息!
FMINCON only accepts inputs of data type double.
错误指示是这一行:
= fmincon(@myobjfun,x0,A,b,@data_preprocess(a1,kmax),beq,lb,ub);
回复 1 # 花千树 的帖子
看下这帖, LZ或许会瞭解为何仅有看, 没人回的原因!
提问的智慧!!!!(发帖前请认真阅读) http://forum.vibunion.com/thread-21991-1-1.html
1.别人怎复製LZ的状况!?
2.即然知道那一行错误, 又知道是data type的问题, 就用whos或workspace看看那个不是!
页:
[1]