Project

Code to plot drag force as a function of velocity for different drag co-efficients

% Drag Force
clear all
close all
clc

% Inputs
drag_coefficient = input('Enter the value of drag co-efficient:');
rho = input('Enter the density of the medium(kg m^-3):');
A = input('Enter the value of the frontal area(m^2):');
v1 = input('Enter minimum veloity(ms^-1):');
v2 = input('Enter maximum velocity(ms^-1):');
v = [v1:v2];

%Calculations
drag = 0.5*drag_coefficient*rho*A*v.^2;

%Results
figure(1);
plot(v,drag);
xlabel('Velocity (ms^-1)');
ylabel('Drag force (N)');

% Drag co-efficient for various shapes
d_sphere = 0.47;
d_halfsphere = 0.42;
d_cone = 0.5;
d_cube = 1.05;
d_angledcube=0.8;
d_longcylinder = 0.82;
d_shortcylinder = 1.15;
d_streamlinedbody = 0.08;
d_halfstreamlinedbody = 0.04;
d_c = [d_sphere d_halfsphere d_cone d_cube d_angledcube d_longcylinder d_shortcylinder d_streamlinedbody d_halfstreamlinedbody];
% Calculations:
vel = input('Enter velocity:');
d = 0.5*rho*(vel^2)*A*d_c;
figure(2);
plot(d_c,d);
xlabel('Drag co-efficient');
ylabel('Drag Force(N)');

for(i=1:length(d_c))
drag_force = 0.5*rho*d_c(i)*v.^2;
figure(3);
plot(v,drag_force);
hold on;
xlabel('Velocity(ms^-1)');
ylabel('Drag Force(N)');
end

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.