Clear Filters
Clear Filters

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 use.

1 view (last 30 days)
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.

Accepted Answer

Aykut Satici
Aykut Satici on 19 Aug 2014
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')
  2 Comments
sv
sv on 21 Aug 2014
Thanks sir for your reply. Sir, I have made some changes in the above code according to my problem. But i am not getting any output. My code is function dd [t,y]=ode15s(@odefun,[0, 0.005],1.005); %plot(t,y(:,1),'-o') y(:,1) %grid end function dy =odefun(t,y) a=250; b= 1E+5; dy=sqrt((a*(1-(1/y(1))^4))+ b*log(y(1)));
c1 = 0.9965; c2 = 25.17*(10e-4);
num1 = c2; den1 =(1-(y.^3)/(4.201)); z = sqrt(c1+num1./den1); num2 =z.^2.* 0.0066; den2= 0.9996-z.^2; l=(num2./den2); num3=0.0014*(10e-4); den3=((1-4.2008/y.^3).^2.*(1-1.0502/y.^3)); c4 =0.00348; k=((num3./den3)+c4); eta=abs(l*k); % Visualize f = figure(1); clf axis([0,0.005,0,2]) %set the range of x and y subplot(2,1,1) plot(t, y(:,1)) ylabel('y') subplot(2,1,2) plot(t, eta) xlabel('t') ylabel('eta') grid end
In this code i want to use the values of y to plot a graph between eta and t. But i am not getting the plot. Kindly help me.
Aykut Satici
Aykut Satici on 21 Aug 2014
I am not sure what error you are getting, in particular. But you are probably looking for something like what I have attached.
My code may not be exactly what you want so please check.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!