Help with projectile trajectory problem

Hi, im new using this software and i really need some help to make my code run. The teacher ask me to resolve this problem using matlab, but i dont really know if im doing well. It's about a projectile trajectory, i need to get the angle theta to get de code run.
This are the initial conditions:
m=15 [kg] g=-9.81 [m/s^2] v0=100 [m/s]
When the projectile touch the ground: xmax=300 [m] ymax=-50 [m]
Also he give me the eqn: my''=F
clear all;clc;close all
%%Constantes
syms theta
m=15; % [kg]
v0=100; % [m/s]
g=9.81; % [m/s^2]
x0=0; % [m]
y0=0; % [m]
ymax=-50; %[m]
xmax=300; % [m]
t=0; % [s]
%%Formulas
v0x=v0*cos(theta);
v0y=v0*sin(theta);
t=(xmax/(v0*cos(theta)));
x=v0x*t + x0;
y=(v0y*t-0.5*g*(t^2)+y0);
eq=xmax*tan(theta)-0.5*g*(xmax/(v0*cos(theta)))^2==ymax;
%%Para Theta
Angulo=solve(eq,theta);
vpa(Angulo);
for i=1:4;
Angul=0;
if ans(i)>0;
Angul(i)=ans(i)*180/pi;
Angul(i)=double(Angul(i));
if Angul(i)>0 && Angul(i)<90
Respuesta=Angul(i);
fprintf('El angulo del disparo del cañon es de %f\n',Angul(i));
end
end
end
%%Ploteo
hold on
for theta=Respuesta;
t=(xmax/(v0*cos(theta)));
ezplot(x,y,'b');
end
I think im not doing well the code, but ill wait for awnsers.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by