I have two differential equations I would like to solve simultaneously using ode45 in Matlab, shown below. The problem I have is that the second differential equation is actually d(y^3)/dt, i.e. the derivative of y^3 with respect to t. How do I express this?
function dydt=odefcnNY(t,y,D,Cs,rho,r0,Af,N,V)
dydt=zeros(2,1);
dydt(1)=(3*D*Cs/rho*r0^2)*(y(1)/r0)*(1-y(2)/Cs);
dydt(2)=(D*4*pi*r0*N*(1-y(2)/Cs)*(y(1)/r0)-(Af*y(2)/Cs))/V;
end
D=4e-9;
rho=1300;
r0=10.1e-6;
Cs=0.0016;
V=1.5e-6;
W=4.5e-8;
N=W/(4/3*pi*r0^3*rho);
Af=0.7e-6/60;
tspan=[0 75000];
y0=[r0 Cs];
[t,y]=ode45(@(t,y) odefcnNY(t,y,D,Cs,rho,r0,Af,N,V), tspan, y0);
plot(t,y(:,1),'-o',t,y(:,2),'-.')