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 Center および File ExchangeNonlinear 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