7 views (last 30 days)

This question was flagged by John D'Errico

-----------------------------------------------------------------------

clc

clear all

format long

x = [2 1 0.666666667 0.5 0.4 0.33333 0.285714 0.25 0.22222 0.2];

y = [4.4661998 3.09281539 2.685948193 2.784406211 3.011748832 3.591154269 4.108564714 4.306224216 5.041999859 5.766547107 ];

%data values

p = polyfit(x,y,3)

kk= polyval(p,x)

plot(x,y,x,kk,'o')

------------------------------------------------------------------------------

clc

clear all

format long

N= 50;

aa = [2 1 0.666666667 0.5 0.4 0.33333 0.285714 0.25 0.22222 0.2];

cd = [4.4661998 3.09281539 2.685948193 2.784406211 3.011748832 3.591154269 4.108564714 4.306224216 5.041999859 5.766547107 ];

%data values

aa_ini = 0; aa_end=2;

aa_vector = linspace(aa_ini, aa_end, N);

cd_ls = interp1(aa, cd, aa_vector);

cd_cs = spline(aa, cd, aa_vector);

cd_aa13_ls = cd_ls(49)

cd_aa13_cs = cd_cs(49)

% Plotting data points and interpolation line

figure(1)

plot(aa, cd,'o'); hold on

plot(aa_vector, cd_ls, '--');

plot(aa_vector, cd_cs);

plot(aa_vector(8), cd_aa13_cs, 'square');

plot(aa_vector(8), cd_aa13_ls, '+');

Alan Stevens
on 23 Nov 2020

You can do it as follows. Notice that there are, in effect, only four paramters to fit:

x = 0:0.5:5; % mg/L

k = [0, 0.223904, 0.323333, 0.372308, 0.359143, 0.332033, 0.278462, ...

0.243394, 0.232222, 0.198334, 0.173414]; % d^-1

% In the following function r(1) = b/a, r(2) = c/a, r(3) = d/a, r(4) = e/a

f = @(x, r) x./(r(1) + r(2)*x + r(3)*x.^2 + r(4)*x.^3);

r0 = ones(4,1);

r = fminsearch(@(r) fcn(r,x,k,f),r0);

xx = 0:0.01:5;

kfit = f(xx,r);

plot(x,k,'o',xx,kfit),grid

xlabel('x'),ylabel('k')

legend('data','curvefit')

function F = fcn(r,x,k,f)

y = f(x,r);

F = norm(y-k);

end

This results in the following

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

Start Hunting!
## 4 Comments

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1154233

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1154233

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1154253

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1154253

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1154283

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1154283

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1160068

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/658538-how-do-you-solve-the-non-growth-rate-of-yeast-using-non-linear-regression-analysis#comment_1160068

Sign in to comment.