Project

Matlab program to calculate drag force, the factors involved are Velocity, Drag coefficient, Frontal Area & Density of air

%To calculate drag force on a Bicycle and plot Drag force vs Velocity
clear all
close all
clc

%Inputs
c_d = 0.8; %drag coefficient

A = 0.25; %frontal area (m^2)

rho = 1.6; %density of air (kg/m^3)

v = linspace(0,50,100); %velocity (m/s)

drag_force = 0.5*rho*A*(v.^2 )*c_d; %drag force (kg-m/s^2)

plot(v,drag_force)
title('Drag Force vs Velocity')

xlabel('Velocity')
ylabel('Drag Force')

grid on
grid minor

%End of Code 1

--x--x--x--x--x--

%To calculate drag force for various shapes with same frontal area(0.1 m^2)
clear all
close all
clc

%Inputs
c_d = [0.47 0.42 0.5 1.05 0.8 0.82 1.15 0.04 0.09]; %drag coefficients of various shapes

A = 0.1; %frontal area (m^2)

rho = 1.2; %density of air (kg/m^3)

v = 10; %velocity (m/s)

drag_force = 0.5*rho*A*v^2.*c_d; %drag force (kg-m/s^2)

%Point Legends
C={'Sphere - 0.47','Half-sphere - 0.42','Cone - 0.5','Cube - 1.05','Angled cube - 0.8','Long cylinder - 0.82','Short cylinder - 1.15','Streamlined body - 0.04','Streamlined half body - 0.09'};

figure(1)
hold on
for k=1:length(c_d)
scatter(c_d(k),drag_force(k))
end
plot(c_d,drag_force)
hold off
title({'Drag Force vs c_d for various shapes';'(with same frontal area(0.1 m^2))'}')
hl=legend(C,'Location','NEO');
title(hl,'Shape - c_d')

xlabel('Coefficient of drag for various shapes')
ylabel('Drag Force')
grid on
grid minor

%End of Code 2

--x--x--x--x--x--

%To calculate drag force for various shapes with same width(0.5 m)
clear all
close all
clc

%Inputs
c_d = [0.47 0.42 0.5 1.05 0.8 0.82 1.15 0.04 0.09]; %drag coefficients of various shapes

A(1)= pi*0.5*0.5/4; %frontal area of sphere(m^2)
A(2)= pi*0.5*0.5/4; %frontal area of half-sphere(m^2)
A(3)= pi*0.5*0.5/4; %frontal area of cone(m^2)
A(4)= 0.5*0.5; %frontal area of cube(m^2)
A(5)= 0.5*0.5*2^0.5; %frontal area of angled cube(m^2)
A(6)= pi*0.5*0.5/4; %frontal area of long cylinder(m^2)
A(7)= pi*0.5*0.5/4; %frontal area of short cylinder(m^2)
A(8)= 0.5*0.1; %frontal area of streamlined body with height 0.1m (m^2)
A(9)= 0.5*0.05; %frontal area of streamlined half-body with height 0.05m (m^2)

rho = 1.2; %density of air (kg/m^3)

v = 10; %velocity (m/s)

%Drag Force (kg-m/s^2)

for i=1:length(c_d)
drag_force(i) = 0.5*rho*A(i)*v^2*c_d(i);
end

%Point Legends

C={'Sphere - 0.47','Half-sphere - 0.42','Cone - 0.5','Cube - 1.05','Angled cube - 0.8','Long cylinder - 0.82','Short cylinder - 1.15','Streamlined body - 0.04','Streamlined half body - 0.09'};

%Plotting

figure(1)
hold on
for k=1:length(c_d)
scatter(c_d(k),drag_force(k))
end
hold off
title({'Drag Force vs c_d for various shapes';'(with same width(0.5 m))'}')
hl=legend(C,'Location','NEO');
title(hl,'Shape - c_d')

xlabel('Coefficient of drag for various shapes')
ylabel('Drag Force')
grid on
grid minor

%End of Code 3

--x--x--x--x--x--

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.