Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Resolve confusion

...

Code Block
 function [x, y] = trajectory(initialSpeed, initialAngle, height)
    dt =0.01;
    xxPos = 0; % Nåværende verdi for x
    yyPos = height ; % Nåværende verdi for y
    [vx , vy] = initVelocity(initialAngle ,initialSpeed);
    i = 1;
    while yyPos > 0
        % kalkuler akselerasjon
        [ax , ay] = acceleration(vx, vy);
         
        % kalkuler fart
        [vx , vy] = velocity(ax, ay, vx, vy, dt);
 
        % kalkuler endring i distanse
        [axPos, byPos] = position (xxPos, yyPos, vx, vy, dt);
        x(i) = axPos;
        y(i) = byPos;
        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 

...