sábado, 22 de julio de 2017

CÓDIGO EN MATLAB QUE GRAFIQUE TIRO PARABÓLICO

%Se pide realizar un código en matlab que grafique el tiro parabólico
%que realiza una partícula. Los datos que se deben ingresan por teclado serán: 
%•  Velocidad inicial.
%•  Angulo
%•  Posición inicial en x

%•  Posición inicial en y


clc
clear all

h = input('Ingrese la altura inicial : ');
vo = input('Ingrese la velocidad inicial en m/s: ');
angulo = input('Ingrese el angulo : ');
teta = angulo*pi/180;

g = 9.8 ;
syms vy t vy1 y
vy = solve('vy = (vo*sin(teta))-(g*t)',vy)
tiempo = solve(vy,t)
t = subs(tiempo)
disp(t)
Tiempo = double(t)

TiempoF = 2.*Tiempo;

disp(TiempoF)

TiempoT = [0:0.0001:TiempoF];
Xmax = vo*cos(teta).*TiempoT;
disp(Xmax);
xmax = vo*cos(teta)*TiempoF;
disp(xmax)
ymax = h + ((vo*sin(teta))^2)/(2*g);
disp(ymax);
y = h + (vo*sin(teta)).*TiempoT-(0.5*g).*(TiempoT.^2);

subplot(2,2,1);
plot(TiempoT,y,'b'),grid on



subplot(2,2,2);
comet(TiempoT,y), title('Grafica Y vs t'),xlabel('t[segundos]'),ylabel('X[metros]');



y2 = h + (tan(teta).*Xmax)-(0.5*g/(vo*cos(teta))^2).*(Xmax.^2);
subplot(2,2,3);
plot(Xmax,y2,'g'),grid on


subplot(2,2,4);
comet(Xmax,y2), title('Grafica Y vs X'),xlabel('X[metros]'),ylabel('Y[metros]');