-1
???Improper assignment with rectangular empty matrix
Error in task3, 18
y(:,1)=log(r);
錯誤仍然存在,我不知道該怎麼辦。下面使用矩形空矩陣不當分配0
function task3
time=xlsread('Kinetics_data.xls','B3:B82');
Conc=xlsread('Kinetics_data.xls','C3:C82');
CAo=0.050;
CBo=0.0406;
h=0.5;
n=length(Conc);
%Calculate the reaction rate using the forward difference equation and
%eliminate outliners if necessary.
global CA CB
t=time(2:n-1);
CA=Conc(2:n-1);
CB=CBo-(CAo-CA);
r=(-Conc(3:n)+Conc(1:n-2))/(2*h);
y(:,1)=log(r);
X(:,1)=ones(size(CA));
X(:,2)=log(CA);
X(:,3)=log(CB);
[b bint resid residint stats]=regress(y,X);
b;
bint;
k=exp(b(1));
kint=exp(bint(1,:));
b(1)=k;
% Set initial guess of parameter value.
m0=b;
% Set lower and upper bounds for the parameters
ub=[2.981770068869469 1.515475186852946 0.914563691229481];
lb=[1.354032677809809 0.938815382572068 0.753329300963922];
options=optimset('TolX',1e-16,'TolFun',1e-16,'MaxFunEval',4000,'MaxIter',4000);
[m,residn,resid,exiflage,output,lamda,Jacob]=lsqcurvefit(@ratefun,m0,t,r,lb,ub,options)
end
'r'可能是空的。 – Justin 2013-04-03 21:55:49
學習使用調試器的時間。想想錯誤信息告訴你什麼。看看正在製作什麼。如果一個矩陣是空的,請考慮!!!!!!問自己爲什麼。 – 2013-04-03 21:59:42
'y(:,1)= log(r);'這行不會出現在腳本的任何位置? – 2013-04-04 05:54:27