MATLAB: Problems coding to find function values

excelinflection pointsnumerical differentiation

Hello
I'm a biology student trying to use matlab, my mathematical and informatic knowledge is thereby limited. However I've tried to write some code to obtain the following:
I have a function y=f(t) that describes the growth of every individual. y=f(t) has 8 variables that are constant but are different for each individual. The velocity curve is obtained by differentiating the y=f(t) function. a picture of both the growth and velocity curve can be seen below. The red curve is the growth curve and the blue curve the velocity curve.
the function is described by y(t)= m1*(1-1/(1+(m2*(m0+m8))^m5+(m3*(m0+m8))^m6+(m4*(m0+m8))^m7)). t is here the independent variable. m1 to m8 are variables that are constant for each individual but differ between individuals.
What I would like to obtain is -the inflection points (both t and f(t) values) of the growth function – the asymptotic value of the growth function – the corresponding maximum height of the differentiated function – the minimum height of the differentiated function before the maximum height is reached
If tried to write some code trying to obtain all the information listed above. However there seem to be some bugs. If anybody is willing to help me out I would be very gratefull
if true
% code
% set variabelen
syms t;
m1=xlsread('jongens0','A1:A10');
m2=xlsread('jongens0','B1:B10');
m3=xlsread('jongens0','C1:C10');
m4=xlsread('jongens0','D1:D10');
m5=xlsread('jongens0','E1:E10');
m6=xlsread('jongens0','F1:F10');
m7=xlsread('jongens0','G1:G10');
m8=xlsread('jongens0','H1:H10');
% set loop
for i=1:10
% define function and differentiated function
y(i)=m1(i).*(1-1./(1+(m2(i).*(t+m8(i))).^m5(i)+(m3(i).*(t+m8(i))).^m6(i)+(m4(i).*(t+m8(i))).^m7(i)));
dy(i)=diff(y(i))./dt;
% information extraction
a=max(dy(i));
b=fminsearch(dy(i),x0,[0,a]);
c=max(y(i));
d=limit(y(i),inf);
e=inflect_pt((y(i)));
A = [a b c d e]
% write information to excel
xlswrite('output0',A)
end

Best Answer

Since you are using an explicit, continuous function to approximate your growth curve, there is no point in dealing with discrete approximations to this curve for the purpose of finding its inflection points. Your function is
y(t) = m1*(1-1/u(t))
where
u(t) = 1+(m2*(t+m8))^m5+(m3*(t+m8))^m6+(m4*(t+m8))^m7
All the quantities you are seeking depend on the inflection points, which is to say, the values of t where the second derivative of y(t) is zero. Simple calculus will give you
d^2y/dt^2 = m1/(du/dt)^3*(u*d^2u/dt^2-2*(du/dt)^2)
Thus your problem is to find the values of t such that
u*d^2u/dt^2-2*(du/dt)^2 = 0
The derivatives of u are easy to find:
du/dt = m2*m5*(t+m8)^(m5-1)+m3*m6*(t+m8))^(m6-1)+m4*m7*(t+m8))^(m7-1)
d^2u/dt^2 = m2*m5*(m5-1)*(t+m8)^(m5-2) + etc.
Now for the first time you can use matlab by way of its 'fzero' function to find the t-roote where u*d^2u/dt^2-2*(du/dt)^2 is zero. I'll let you take it from there.