while fitting my model data to experimental data the resultant curve is shooting very high and is not matching with experimental time points, even on changing ub and lb

3 次查看(过去 30 天)
% Experimental data
t1=[0 6 12 18 36 48]; % time points
nfe2=[0.9 1.57 2.87 3.9 5.16 4.25]; %level of protein
t=1:1:48; %simulation time
% ODE equation
ode_eqn = @(x, t)integrate_a(x, t); %ODE equation to fit
x0 = [0.04 0.055]; % Initial guess for the parameters
% Least squares curve fitting using lsqcurvefit
x_fit = lsqcurvefit(ode_eqn, x0, t1, nfe2);
Local minimum possible. lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
disp("Fitted parameters using lsqcurvefit:")
Fitted parameters using lsqcurvefit:
disp(x_fit)
1.1792 0.0282
% Nonlinear programming using fmincon
options = optimoptions('fmincon', 'Algorithm', 'interior-point');
x_fit_constrained = fmincon(@(x) sum((ode_eqn(x, t1) - nfe2).^2), x0,[],[],[],[],[0 0],[10 10],[],options);
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
disp("Fitted parameters using fmincon:")
Fitted parameters using fmincon:
disp(x_fit_constrained)
1.1792 0.0282
% Plotting results
t_fit = linspace(1, max(t1),49); % Time points for plotting fitted curve
figure;
plot(t1, nfe2, 'bo', 'MarkerSize', 8, 'LineWidth', 1.5); % Plot experimental data
hold on;
plot(t_fit, ode_eqn(x_fit, t_fit), 'r-', 'LineWidth', 2); % Plot fitted curve using lsqcurvefit
plot(t_fit, ode_eqn(x_fit_constrained, t_fit), 'g--', 'LineWidth', 2); % Plot fitted curve using fmincon
hold off;
legend('Experimental Data', 'lsqcurvefit', 'fmincon');
xlabel('Time');
ylabel('Data');
title('Fitting Experimental Data to ODE Equation');
%%
function ifn = integrate_a(x, t)
%nf=[0.9 3.3 6.8 5.7 4.02 ];
%f=[100 98.31 35.5 12.85 4.68];
ifn=zeros(size(t));
for i=1:numel(t)
if t(i)<6.48
cd(i)=1;
else
cd(i)=(1- 0.0683)*exp(-0.0240*(t(i) - 6.48)) + 0.0683;
end
c=cd;
if t(i)<4
inf(i)=0.9;
else
inf(i) = inf(i-1)+ (cd(i).*x(1)- inf(i-1).*x(2));
end
ifn=inf;
end
end
  1 个评论
Matt J
Matt J 2023-6-16
the resultant curve is shooting very high and is not matching with experimental time points
That's nothing we can diagnose for you. It's possible your model is just unsuitable to the data.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2023-6-16
Are you just trying to fit this equation:
cd(i) = (1- 0.0683) * exp(-0.0240*(t(i) - 6.48)) + 0.0683;
If so use fitnlm. I'm attaching some demos. Adjust the equation/formula as needed.
  3 个评论
Image Analyst
Image Analyst 2023-6-17
I don't know what a "waty" is.
Also inf is a contant in MATLAB. It means "infinity". So I'm not sure what your equation means. Usually operations using infinity end up giving infinity again. For example inf(5) will give a 5x5 array of infinity values
i = 5;
a = inf(i)
a = 5×5
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
So you can't have inf(i) on the left hand side of the equation.
SWAPNAVA
SWAPNAVA 2023-6-17
no "inf" is a variable. i have changed to "infron" still I am getting the model output curve but it is reaching till 25 along y xis where experimental data is till 5 only maximum along y axis.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Nonlinear Least Squares (Curve Fitting) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by