i want to plot a equation dy/dt=Sqrt ((1-1/y^4)+log(y)). What type of ode solver should i use. The initial value of y at t=0 is 1.005. Also the limits of t are 0 to 0.05.

function bb [t,y]=ode(@odefun,[0 0.05],1.005); plot(t,y(:,1),'-o') end
function dy =odefun(t,y) a=250; b= 1e5; dy=(a*(1-1/y(1)^4)+b*log(y(1))); end
This code is not solving my problem.

 採用された回答

Your ODE function .m file ‘odefun’ will work. (I used an anonymous function for your ODE, because it’s more convenient for me.) You can use ode45 to integrate your ODE:
odefun = @(t,y) (250*(1-1./y(1).^4)+1E+5.*log(y(1)));
[t,y]=ode45(odefun,[0 0.05],1.005);
figure(1)
plot(t,y(:,1),'-o')
grid

2 件のコメント

sv
sv 2014 年 8 月 18 日
Thanks Sir for your answer. This was really helpful.
Star Strider
Star Strider 2014 年 8 月 18 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

sv
2014 年 8 月 17 日

コメント済み:

2014 年 8 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by