1 view (last 30 days)
El Pepeno on 20 Jan 2020
Edited: Jim Riggs on 20 Jan 2020
Goal:
I'm trying to implement friction into this script of a launch of a missile.
The friction force should be related to the velocity like: Ff = -gamma|v|v.
Subsequently we also have the gravity force acting on the missile: Fg = mg.
The values of ad should be as follows, but I am unable to get this desired output:
ad = [300332, 302763, 303903, 303771, 302384, 299763, 295927, 290896, 284693];
for degrees of launch 37, 39, 41, 43, 45, 47, 49, 51, 53 respectively.
Script:
clear;
close all;
clc;
tic
m = 500;
aT = [];
gamma = 1.0e-5
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 = 2000;
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;
FgY = m * gy;
FgX = m * gx;
FricY = gamma*abs(vy)*vy;
FricX = gamma*abs(vx)*vx;
FnetY = FgY - FricY;
FnetX = FgX - FricX;
vy = vy - (gy * dt) - (FnetY / m)*dt; % This should substract gravity and friction from the velocity, not sure if this is correct.
vx = vx - (gx * dt) - (FnetX / m)*dt; % Same for this line of code
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;
fprintf('Checked for degree: %.0f\n', i)
end
toc
Output:
ad = [200358, 203662, 205972, 207257, 207539, 206800, 205056, 202324, 198615];
for degrees of launch 37, 39, 41, 43, 45, 47, 49, 51, 53 respectively.
Any help / suggestions are immensly appreciated!
the cyclist on 20 Jan 2020
I'm not able to run the code right now, but one suggestion I have is to run your code without the frictional force (for which you can calculate the correct answer by hand), and see if your code is giving the correct answer for that. That way you'll know if it is the friction calculation that is wrong, or something else.

Jim Riggs on 20 Jan 2020
Step 1: Draw a free body diagram that shows the body with all of the forces that act on it and the coordinate frame(s) that are being used.
Step 2: For a point-mass in 2 dimensions, you should be able to use the free body diagram (by inspection) to ensure that you are calculating the force components correctly; sum of the forces in X = m*Ax, sum of forces in Y = m*Ay.
Are forces defined in body or inertial axes? (The aerodynamic force is usually in body axes, but the gravity force is defined in Inertial axes)
Show us this drawing and we can work from there.
El Pepeno on 20 Jan 2020
Thank you so much for the help, I will try to figure it out now.
Much appreciated, have a nice week!
{"ft_lang_label":"__label__en","ft_lang_prob":0.68488574,"math_prob":0.99721855,"size":1595,"snap":"2021-43-2021-49","text_gpt3_token_len":679,"char_repetition_ratio":0.07416719,"word_repetition_ratio":0.057636887,"special_character_ratio":0.53103447,"punctuation_ratio":0.26682693,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99949384,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-26T21:19:48Z\",\"WARC-Record-ID\":\"<urn:uuid:7a575ae2-5817-492b-a07c-2e42038d5a73>\",\"Content-Length\":\"213471\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b06233b7-38ac-4127-a39a-2856b74367f2>\",\"WARC-Concurrent-To\":\"<urn:uuid:207c12d0-cb13-4b8a-9c31-fa831dd3aec2>\",\"WARC-IP-Address\":\"104.117.0.182\",\"WARC-Target-URI\":\"https://ch.mathworks.com/matlabcentral/answers/501120-missile-lauch-friction-gamma-factor-output-deviating-from-desired-output-please-help\",\"WARC-Payload-Digest\":\"sha1:R6AJYFWNBXQRP6M6R5WBJ5ZRPTFQFJOV\",\"WARC-Block-Digest\":\"sha1:XJ3JRNJU5UW7MLEKBQTQWPWMSPALJ2FD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323587926.9_warc_CC-MAIN-20211026200738-20211026230738-00684.warc.gz\"}"}