h = 10;
angle = 45;
v = 45;
g=-9.81;
angles = 0:10:180;
heights = 0:40:200;
velocity = 10:10:100;
figure
for a = angles
[x_val,y_val] = Arc(g,h,a,v);
and = plot(x_val,y_val);
hold on;
end
xlabel 'x (m)'
ylabel 'y (m)'
title 'Angles 0-180'
legend ('0 degrees', '10 degrees', '20 degrees', '30 degrees', '40 degrees', '50 degrees', '60 degrees', '70 degrees', '80 degrees', '90 degrees', '100 degrees', '110 degrees', '120 degrees', '130 degrees', '140 degrees', '150 degrees', '160 degrees', '170 degrees', '180 degrees');
figure
for hi = heights
[x_val,y_val] = Arc(g,hi,angle,v);
m_hi = [x_val', y_val'];
max2 = max(max(m_hi));
plot(x_val,y_val);
hold on;
axis([0 max2*1.05 0 max2*1.05]);
end
xlabel 'x (m)'
ylabel 'y (m)'
title 'Height 0-100 (m)'
legend ('H = 0','H = 40','H = 80','H = 120','H = 160','H = 200');
figure
for vel = velocity
[x_val,y_val] = Arc(g,h,angle,vel);
m_vel = [x_val', y_val'];
max3 = max(max(m_vel));
plot(x_val,y_val);
hold on;
axis([0 max3*1.05 0 max3*1.05]);
end
xlabel 'x (m)'
ylabel 'y (m)'
title 'Velocity 10-100 (m/s)'
legend ('10 m/s','20 m/s','30 m/s','40 m/s','50 m/s','60 m/s','70 m/s','80 m/s','90 m/s','100 m/s');
[x_val,y_val] = Arc(g,h,angle,v);
m = [x_val',y_val'];
max_val = max(max(m));
figure
plot(x_val,y_val,'r');
hold on;
[~,idx] = max(y_val);
plot(x_val(idx),y_val(idx),'b-')
text(x_val(idx),y_val(idx),'max','VerticalAlignment','Bottom','HorizontalAlignment','Left','FontSize',8)
axis([0 max_val*1.05 0 max_val*1.05]);
xlabel 'x (m)'
ylabel 'y (m)'
title 'Original Data'
legend 'User Data,'
function [x_val,y_val] = Arc(g,h,angle,v)
y = h;
t = 0;
x_val = [];
y_val = [];
while y >= 0
y=.5*g*t.^2+v*sind(angle)*t+h;
x=v*cosd(angle)*t;
t = t + 0.01;
x_val = [x_val,x];
y_val = [y_val,y];
end
end