# Curvilinear Motion

Solution

draw_path.m

function [x, y] = draw_path(v0, s0, theta)

i = 0;

x = [];

y = [];

while(1)

x = [x; v0 * cos(theta) * i];

y = [y; s0 + v0 * sin(theta) * i – 4.9 * i * i];

if(i ~= 0 & y(i + 1) <= 0)

x(i+1) = x(i) + (x(i+1) – x(i)) * y(i) / (y(i) – y(i+1));

y(i+1) = 0;

break;

end

i = i + 1;

end

get_H.m

functionrlt = get_H(s, v, theta)

rlt = s + v * sin(theta) * v * sin(theta) / 19.6;

get_kinetic_energy.m

function [time_val, energy_val] = get_kinetic_energy(m, v, s, theta)

vx = v * cos(theta);

vy = v * sin(theta);

g = 9.8;

time_val = [];

energy_val = [];

t = 0;

while(true)

time_val = [time_val; t];

vy1 = vy – g * t;

energy = m * (vx * vx + vy1 * vy1) / 2;

energy_val = [energy_val; energy];

t = t + 0.1;

cur_s = s + vy * t – g * t * t / 2;

if(cur_s<= 0)

break;

end

end

v0 = 100;

s0 = 1200;

theta = 45;

theta = theta * (2 * pi) / 360;

[x, y] = draw_path(v0, s0, theta);

figure;

plot(x, y, ‘r’, ‘linewidth’, 3);

Max_height = v0 * v0 / (2 * 9.8);

Range = x(i+1);

s0 = [0:500:5000];

v0 = [100:100:1100];

theta = [15:6:75];

theta = theta * (2 * pi) / 360;

subplot(1,3,1);

title(‘changing initial position’);

hold on;

for i = 1: 11

[x, y] = draw_path(v0(1), s0(i), theta(1));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

subplot(1,3,2);

title(‘changing velocity’);

hold on;

for i = 1: 11

[x, y] = draw_path(v0(i), s0(1), theta(1));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

subplot(1,3,3);

title(‘changing angle’);

hold on;

for i = 1: 11

[x, y] = draw_path(v0(1), s0(1), theta(i));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

s0 = [0:500:5000];

v0 = [100:100:1100];

theta = [15:6:75];

m = [1:1:11];

theta = theta * (2 * pi) / 360;

subplot(2,3,1);

title(‘changing initial position’);

hold on;

for i = 1: 11

[x, y] = get_kinetic_energy(m(1), v0(1), s0(i), theta(1));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

subplot(2,3,2);

title(‘changing velocity’);

hold on;

for i = 1: 11

[x, y] = get_kinetic_energy(m(1), v0(i), s0(1), theta(1));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

subplot(2,3,3);

title(‘changing angle’);

hold on;

for i = 1: 11

[x, y] = get_kinetic_energy(m(1), v0(1), s0(1), theta(i));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

subplot(2,3,4);

title(‘changing material’);

hold on;

for i = 1: 11

[x, y] = get_kinetic_energy(m(i), v0(1), s0(1), theta(1));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

subplot(2,3,5);

title(‘changing velocity & angle’);

hold on;

for i = 1: 11

[x, y] = get_kinetic_energy(m(1), v0(i), s0(1), theta(i));

plot(x, y, ‘r’, ‘linewidth’, 3);

end

hold off;

s0 = [0:50:5000];

v0 = [100:1:1100];

theta = [15:0.1:75];

m = [1:0.1:11];

theta = theta * (2 * pi) / 360;

f = [];

for mm = 1: 0.1: 11

tmp_f = mm * v0(1) * cos(theta(1));

f = [f; tmp_f];

end

subplot(2,4,1);

plot(m, f, ‘r’, ‘linewidth’, 3);

title(‘changing mass at the max H’)

f = [];

forvv = 100: 1: 1100

tmp_f = m(1) * vv * cos(theta(1));

f = [f; tmp_f];

end

subplot(2,4,2);

plot(v0, f, ‘r’, ‘linewidth’, 3);

title(‘changing velocity at the max H’)

f = [];

[dummy, len] = size(theta);

for i = 1: len

tmp_f = m(1) * v0(1) * cos(theta(i));

f = [f; tmp_f];

end

subplot(2,4,3);

plot(theta, f, ‘r’, ‘linewidth’, 3);

title(‘changing angle at the max H’)

subplot(2, 4, 4);

f = [];

for i = 0: 50: 5000

tmp_f = m(1) * v0(1) * cos(theta(1));

f = [f;tmp_f];

end

plot(s0, f, ‘r’, ‘linewidth’, 3);

title(‘changing initial h at the max H’)

f = [];

for mm = 1: 0.1: 11

tmp_v = get_H(s0(1), v0(1), theta(1)) * 19.6 + v0(1) * cos(theta(1)) * v0(1) * cos(theta(1));

tmp_v = sqrt(tmp_v);

tmp_f = mm * tmp_v;

f = [f; tmp_f];

end

subplot(2,4,5);

plot(m, f, ‘r’, ‘linewidth’, 3);

title(‘changing mass at the ground’)

f = [];

forvv = 100: 1: 1100

tmp_v = get_H(s0(1), vv, theta(1)) * 19.6 + vv * cos(theta(1)) * vv * cos(theta(1));

tmp_v = sqrt(tmp_v);

tmp_f = m(1) * tmp_v;

f = [f; tmp_f];

end

subplot(2,4,6);

plot(v0, f, ‘r’, ‘linewidth’, 3);

title(‘changing velocity at the ground’)

f = [];

[dummy, len] = size(theta);

for i = 1: len

tmp_v = get_H(s0(1), v0(1), theta(i)) * 19.6 + v0(1) * cos(theta(i)) * v0(1) * cos(theta(i))

tmp_v = sqrt(tmp_v);

tmp_f = m(1) * tmp_v;

f = [f; tmp_f];

end

subplot(2,4,7);

plot(theta, f, ‘r’, ‘linewidth’, 3);

title(‘changing angle at the ground’)

subplot(2, 4, 8);

f = [];

for i = 0: 50: 5000

tmp_v = get_H(i, v0(1), theta(1)) * 19.6 + v0(1) * cos(theta(1)) * v0(1) * cos(theta(1));

tmp_v = sqrt(tmp_v);

tmp_f = m(1) * tmp_v;

f = [f;tmp_f];

end

plot(s0, f, ‘r’, ‘linewidth’, 3);

title(‘changing initial h at the ground’)