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.

조회 수: 2 (최근 30일)
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.

채택된 답변

Aykut Satici
Aykut Satici 2014년 8월 19일
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
sv
sv 2014년 8월 21일
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 2014년 8월 21일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by