% % Método de Heun
clear all
clc
a= 0; b= 20;
n= 40; v0= 300; h = (b - a) / n;
v(1,:) = v0; t(1) = a;
f= @(t,v) -0.0035*v^2 -3;
for i = 1 : n
t(i+1) = t(i) + h;
g = f(t(i),v(i,:));
z = v(i,:) + h * g;
v(i+1,:) = v(i,:) + h/2 * ( g + f(t(i+1),z) );
end;
plot(t, v);
whitebg('k');
title('V vs T, dy/dx= -0.0035v²-3', 'Fontsize', 18);
xlabel('Tiempo', 'Fontsize', 16) ;
ylabel('Velocidad', 'Fontsize', 16);
t=t';
twv0=[t v]