法一:
v=dsolve('Dv=g-k*v^2/m','v(0)=0');
x=dsolve('D2x=9.81-0.22*Dx^2/75','x(0)=0','Dx(0)=0');
m=75;
g=9.81;
k=0.22;
t=0:0.1:25;
v=subs(v);
x=subs(x);
subplot(211)
plot(t,v)
subplot(212)
plot(t,x)
法二:
function bb
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4]);
[t,y] = ode45(@fun,[0,25],[0,0],options);
subplot(211)
plot(t,y(:,1))
subplot(212)
plot(t,y(:,2))
end
function dy=fun(t,y)
m=75;
g=9.81;
k=0.22;
dy=zeros(2,1);
dy(1)=g-k*y(1).^2/m;
dy(2)=y(1);
end