Parameter fit differential equation to dataset
이전 댓글 표시
Hello!
I am trying to fit a differential equation to a dataset by adjusting the equation's parameters (c(1) and c(2)). My datasets consist of an evolution of sealevel (s) over time (t) and temperature (temp) over time. The equation is as follows:
ds/ dt=-(1-c(1))*c(2).*(tempi(t))
My code is not working and was hoping someone could please give me some pointers.
CODE:
function bestc = odeparamAsmb5()
%Initial data
load rcp85_antsmbmidmatlab.txt;
load rcp85_temperaturemidmatlab.txt;
time= rcp85_temperaturemidmatlab(:,1)-2006+1;%modifying the vector from [2006 2100] to [1 95] to match "i"
temp= rcp85_temperaturemidmatlab(:,2)+0.8;
sealevel=rcp85_antsmbmidmatlab(:,2);
plot(time,sealevel)
%information
tempi=@(t) interp1(time,temp,t);
f=@(c,t)-(1-c(1))*c(2).*(tempi(t));
simsealevel= zeros(1,95);
for t=1:1:95
simsealevel(t)= integral(f,t,t+1);
hold on
plot(time,simsealevel, '-r')
end
% Optimise difference between simsealevel and sealevel
fun= @(c,t)-(1-c(1))*c(2).*(tempi(t))- sealevel;
c0= [0.25,0.15];
lb= [0.25;0.15];
ub= [0.25;0.35];
x = lsqnonlin(fun,c0,lb,ub);
ERRORS:
Not enough input arguments.
Error in odeparamAsmb5>@(c,t)-(1-c(1))*c(2).*(tempi(t)) (line 14)
f=@(c,t)-(1-c(1))*c(2).*(tempi(t));
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in odeparamAsmb5 (line 20)
simsealevel(t)= integral(f,t,t+1);
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 State-Space Control Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!