Parameter Estimation for Differential Equation according to data measured
Show older comments
Thanks in advance to all supporters, this is the first time a ask a question - that's because there are answers to most of the problems i had.
After reviewing the proposed solution :

- i tried to apply "Star Strider" ‘Igor_Moura’ function to another ode problem i have but get Error "using lsqcurvefit"
- i did a modification to your code to solve the eq:

- A,B,C are parameters i look for ([A B C] inside the code are theta(1:3). [y,y'] are c(1:2), dcdt(2) is [y''] and x is t)
function C=kinetics(theta,t)
c0=[293;0]; %initial condition
[T,Cv]=ode45(@DifEq,t,c0);
%
function dC=DifEq(t,c)
dcdt=zeros(2,1);
dcdt(1)=c(2);
dcdt(2)=theta(3)-theta(2).*c(1)-theta(1).*t.*c(2);
dC=dcdt;
end
C=Cv;
end
global t c
load('t.mat'); t=t*1000;
load('c.mat');
theta0=[1;1;1]; % initial guess
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);
fprintf(1,'\tRate Constants:\n')
for k1 = 1:length(theta)
fprintf(1, '\t\tTheta(%d) = %8.5f\n', k1, theta(k1))
end
- unfortunately, I encounter a problem of dimensions :
Error using lsqcurvefit (line 248)
Function value and YDATA sizes are not equal.
- at line 199 :

- initVals.F get the size :

- so at line 248 :

- i got the err because YDATA length is 18896X1 so their sizes are not equal.
any idea?? thanks Netanel
Accepted Answer
More Answers (0)
Categories
Find more on Plot Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

