MATLAB: Drag force on a Bicycle
The drag force on a bicycle can be calculated and a plot of velocity versus drag force gives us an idea how drag force increases with velocity exponentially.
Program:
% A program to calculate the drag force on a bicycle
function [D] = drag_parameters(a, v, rho, first, last)
% Inputs
% 1. Frontal Area m^2
% 2. Velocity m/s
% 3. Density kg/m^3 rho = 1.2;
% 4. Drag coefficient
c_d = linspace(first,last,100);
% Drag Force
D = 0.5*rho*v.*v.*a.*c_d;
% Use the command written below with your own input values to get a plot.
% D = drag_parameters(0.1, 1:100, 1.2, 1, 5), v = 1:100, plot(v, D), grid on, xlabel('Velocity'), ylabel('Drag_force')
end
Step wise explanation of the program:
- A function 'drag_parameters' is defined with inputs of frontal area, velocity, density, first value of drag coeffcient, last value of drag coeffcient and an output D.
- The drag coeffcient is defined by 'linspace' command giving 100 values between the inputs - first and last.
- The drag force is defined by the formula D = 0.5*rho*v.*v.*a.*c_d
- In the command window, the function is called with the input values and a plot of velocity vs drag force is obtained.
- Function call:D = drag_parameters(0.1, 1:100, 1.2, 1, 5), v = 1:100, plot(v, D), grid on, xlabel('Velocity'), ylabel('Drag_force')