MATLAB: I want to plot coupled differential-algebraic equations dy/dt=Sqrt ((1-1/y^4)+log(y)) and z=Abs[(3*c​^2)*(4*e^2​)/((1-f^2/​((3*y^3)^2​))*4*(1 – f^2/(12*y^3))). Here c, e, f are constants and their values are known. What type of ode solver should i

coupled differential-algebraic equations

The initial value of y at t=0 is 1.005. Also the limits of t are 0 to 0.05.
I want the plot between z and t, also between y and t.

Best Answer

It seems like only the algebraic equation depends on the solution of the differential equation. Therefore, you can first solve the differential equation with a numerical integration routine, such as "ode45".
You can then use this solution to construct the dependent variable "z". Here is a script that does this:
par = [];
y0 = 1.005;
ti = 0; tf = 0.05;
opt = odeset('AbsTol',1.0e-07,'RelTol',1.0e-07);
[t,y] = ode45(@(t,y,par) sqrt( 1-1/y^4 + log(y) ), [ti,tf], y0 ,opt, par);
% The constants
c1 = 1; % c
c2 = 2; % e
c3 = 3; % f
num = 12*c1^2*c2^2;
den = 4*( 1 - (c3^2)./(3*y.^3).^2 ).*( 1 - (c3^2)./(12*y.^3) );
z = abs( num./den );
% Visualize
f = figure(1); clf
subplot(2,1,1)
plot(t, y)
ylabel('y')
subplot(2,1,2)
plot(t, z)
xlabel('t')
ylabel('z')
Related Question