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.
댓글 수: 0
채택된 답변
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
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 Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!