finding inflection points on different growth functions

1 visualización (últimos 30 días)
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
First the first and second derivative where manually computed
f(t)= m1*(1-1/(1+(m2*(t+m8))^m5+(m3*(t+m8))^m6+(m4*(t+m8))^m7))
u(t)=1+(m2*(t+m8))^m5+(m3*(t+m8))^m6+(m4*(t+m8))^m7
f(t) = m1*(1-1/u(t))
f(t) = m1*((u(t)-1)/u(t))
for simplicity u(t) = u and f(t)=f
f= m1*(u-1)/u
quotient rule du = d(u-1) df = m1*((du*u-du*(u-1))/u^2) df = m1 * du/u^2
quotient rule
d2f = m1*((d2u*u^2-du*d(u^2))/u^4)
*Now what I have written in matlab *
% variables
t=sym('t');
m1=sym('m1');
m2=sym('m2');
m3=sym('m3');
m4=sym('m4');
m5=sym('m5');
m6=sym('m6');
m7=sym('m7');
m8=sym('m8');
%functions and first and second derivative symbolically
u= 1+(m2*(t+m8))^m5+(m3*(t+m8))^m6+(m4*(t+m8))^m7;
f=m1*(u-1)/u;
du=diff(u,t,1);
d2u=diff(u,t,2);
du2=diff(u^2,t,2);
df=m1*(du/u^2)
d2f=m1*((d2u*u^2-du*du2)/u^4)
------------------------------------------------------------------------------- now if i enter this code in matlab it generates
df= (m1*(m2*m5*(m2*(m8 + t))^(m5 - 1) + m3*m6*(m3*(m8 + t))^(m6 - 1) + m4*m7*(m4*(m8 + t))^(m7 - 1)))/((m2*(m8 + t))^m5 + (m3*(m8 + t))^m6 + (m4*(m8 + t))^m7 + 1)^2
d2f=-(m1*((2*(m2*m5*(m2*(m8 + t))^(m5 - 1) + m3*m6*(m3*(m8 + t))^(m6 - 1) + m4*m7*(m4*(m8 + t))^(m7 - 1))^2 + 2*(m2^2*m5*(m2*(m8 + t))^(m5 - 2)*(m5 - 1) + m3^2*m6*(m3*(m8 + t))^(m6 - 2)*(m6 - 1) + m4^2*m7*(m4*(m8 + t))^(m7 - 2)(m7 - 1))((m2*(m8 + t))^m5 + (m3*(m8 + t))^m6 + (m4*(m8 + t))^m7 + 1))*(m2*m5*(m2*(m8 + t))^(m5 - 1) + m3*m6*(m3*(m8 + t))^(m6 - 1) + m4*m7*(m4*(m8 + t))^(m7 - 1)) - (m2^2*m5*(m2*(m8 + t))^(m5 - 2)*(m5 - 1) + m3^2*m6*(m3*(m8 + t))^(m6 - 2)*(m6 - 1) + m4^2*m7*(m4*(m8 + t))^(m7 - 2)(m7 - 1))((m2*(m8 + t))^m5 + (m3*(m8 + t))^m6 + (m4*(m8 + t))^m7 + 1)^2))/((m2*(m8 + t))^m5 + (m3*(m8 + t))^m6 + (m4*(m8 + t))^m7 + 1)^4
--------------------------------------------------------------------------
Now for the next part:
I have an excel file that I have uploaded in my matlab depository. This excel file contains all the values for m1 to m8 for each individual. What I would like is that d2f and df from above are filled in for each individual and that after that calculations are made to find the inflection points:
This is what I've done so far:
m1=xlsread('jongens0','A:A');
m2=xlsread('jongens0','B:B');
m3=xlsread('jongens0','C:C');
m4=xlsread('jongens0','D:D');
m5=xlsread('jongens0','E:E');
m6=xlsread('jongens0','F:F');
m7=xlsread('jongens0','G:G');
m8=xlsread('jongens0','H:H');
% find T1,T2
A=solve(d2f==0,t)
% find H1,H2
B=solve(f==A,t)
% find V1,V2
C=solve(df==A,t)
% find AH
D=limit(f,t,inf)
--------------------------------------------------------
the first part gives me the df and d2f. However when trying to replace the symbolic m's with real values and extract the inflection points there seem to be some problems in my calculations
Anybody would like to help me out?

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Jun. de 2013
Instead of assigning values directly to m1, m2, and so on, use subs()
m1n = xlsread('jongens0','A:A');
m2n = xlsread('jongens0','B:B');
m3n = xlsread('jongens0','C:C');
m4n = xlsread('jongens0','D:D');
m5n = xlsread('jongens0','E:E');
m6n = xlsread('jongens0','F:F');
m7n = xlsread('jongens0','G:G');
m8n = xlsread('jongens0','H:H');
d2fs = subs(d2f, {m1, m2, m3, m4, m5, m6, m7, m8}, {m1n, m2n, m3n, m4n, m5n, m6n, m7n, m8n});
Then you can solve(d2fs, t)

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by