how to get a plot of second ODE
Show older comments
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 Comment
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.
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!