how to get a plot of second ODE
古いコメントを表示
I'm trying to solve a second order ODE and plot it, when I use rk4 method it gives me an arry of yp = NaN and this message is shown : " warning: opengl_renderer: data values greater than float capacity. (1) Scale data, or (2) Use gnuplot"
I'm not able to detect the error in the code. I tried to use ode45 it resulted in the same message.
code:
function trying
clear,clc,clf;
tspan = [0 50]; y0 = [0; 0.1];
step=0.2;
[t, y]=rk4(@f,tspan,y0,step)
plot(t,y)
end
function yp=f(t,y)
yp=zeros(2,1);
j = 6.5*10^-5;
yp(1)=y(2);
yp(2)= y(1) / (t.*j) - (y(1)/(t.^2 .*j)) - (3.*y(2)./t)
end
1 件のコメント
If gnuplot is suggested, this is not Matlab, but Octave. Please remember, that this is a Matlab forum.
rk4() is not a function of Matlab.
A clear on top of a function is a complete waste of time.
6.5*10^-5 is an expensive power operation, while 6.5e-5 is a cheap constant.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!