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 回表示 (過去 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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!