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 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
% 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);
disp("Fitted parameters using lsqcurvefit:")
disp(x_fit)
% 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);
disp("Fitted parameters using fmincon:")
disp(x_fit_constrained)
% 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 comentario
Matt J
el 16 de Jun. de 2023
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.
Respuestas (1)
Image Analyst
el 16 de Jun. de 2023
Are you just trying to fit this equation:
cd(i) = (1- 0.0683) * exp(-0.0240*(t(i) - 6.48)) + 0.0683;
3 comentarios
Image Analyst
el 17 de Jun. de 2023
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)
So you can't have inf(i) on the left hand side of the equation.
Ver también
Categorías
Más información sobre Nonlinear Least Squares (Curve Fitting) en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!