...
Code Block |
---|
function [vx , vy] = velocity(ax, ay, vx, vy, dt) vx = vx + ax * dt; vy = vy + ay * dt; end |
e)
Code Block |
---|
function [xv x, yvy] = trajectory(initialSpeed, initialAngle, height) dt =0.01; x = 0; y = height ; [vx , vy] = initVelocity(initialAngle ,initialSpeed); i = 1; while y > 0 % kalkuler akselerasjon [ax , ay] = acceleration(vx, vy); % kalkuler fart [vx , vy] = velocity(ax, ay, vx, vy, dt); % kalkuler endring i distanse [xa, yb] = position (x, y, vx, vy, dt); xvx(i) = xa; yvy(i) = yb; i = i + 1; end end |
f)
Code Block |
---|
function plotTrajectory(initialSpeed, initialAngle, height) [x, y] = trajectory(initialSpeed, initialAngle, height); plot (x, y); grid on; xlabel('x'); ylabel('y'); title('plotTrajectory'); end |
...