Fit parameters to a non linear differential equation of second order
3 次查看(过去 30 天)
显示 更早的评论
Dear Matlab Community,
I have a non linear differenital equation of first order: L*(dQ/dt)=a*Q+b*(w^2)+c*H+d*Q*(w^2). I have measuring data for Q,w and H and I want to find my parameters L, a, b, c, d. Any idea how I can do this?
Would be really thankful for your help!
Yours
Ann
0 个评论
回答(1 个)
Shaunak
2025-6-10
Hi Ann,
It is my understanding that you have the time-series data for Q, w, and H, and you'd like to estimate five parameters in a nonlinear differential equation that models dQ/dt as a function of these variables.
You can approach this as a nonlinear regression problem using MATLAB’s “lsqnonlin” function from the Optimization Toolbox. You can refer to the following application of the “lsqnonlin” function:
% Given data:
t = time_data; Q = Q_data; w = w_data; H = H_data;
dQdt = gradient(Q, t); % Approximate dQ/dt numerically
% Residual function for least-squares fitting
errorFun = @(p) (p(2)*Q + p(3)*w.^2 + p(4)*H + p(5)*Q.*w.^2) / p(1) - dQdt;
% Initial guess for [L, a, b, c, d]
params0 = [1, 1, 1, 1, 1];
params = lsqnonlin(errorFun, params0);
This will return the parameter estimates that minimize the error between your model and the measured data.
You can refer to the following MathWorks documentation for more information on the “lsqnonlin” function:
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!