How do I implement friction into my script?
Mostrar comentarios más antiguos
clear;
close all;
clc;
tic
aT = 0;
ad = 0;
for i = [37:2:53]
r = 6371 * 10^3;
G = 6.674 * 10^-11;
M = 5.972 * 10^24;
g = (G * M)/(r^2);
theta0 = i;
ax = 0;
ay = r;
v0 = 3000;
vx0 = v0*cosd(theta0);
vy0 = v0*sind(theta0);
x = 0;
y = r;
vx = vx0;
vy = vy0;
T = 0;
dt = 0.01;
at = 0;
landed = 0;
z = 1;
while landed == 0
z = z + 1;
T = T + dt;
xo = x;
yo = y;
x = x + vx * dt;
y = y + vy * dt;
d = sqrt(x^2 + y^2);
alpha = atand(x/y);
g = (G*M)/(d^2);
gy = cosd(alpha) * g;
gx = sind(alpha) * g;
vy = vy - (gy * dt);
vx = vx - (gx * dt);
v = vx/sin(alpha);
ax = [ax, x];
ay = [ay, y];
if d < r
landed = 1;
end
end
aT = [aT, T];
distance = (alpha/360) * 2 * pi * r;
ad = [ad, distance];
fprintf('Checked for degree: %.0f\n', i)
end
toc
This is a model that I've created for calculating the distance a missile travels under the following conditions:
velocity = 2000 m / s
gravity = dependent on height
distance = influenced by curvature of the earth
friction = not present
Now, I am trying to implement friction into my script and I know that the friction force is related to the speed by a coefficient:
Ff = gamma * | v | * v
With Ff and v being vectors in the direction of the missile.
Could anyone please give me a hint to what I could do to implement this relation into the script.
I will then alternate gamma and compare the results of the script to get the best value for gamma.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Gamma Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!