Project

Plotting Coefficient of Drag vs Drag force for incremental changes in the velocity value.

Aim: Plotting graph for Coefficient of Drag vs Drag Force for incremental changes in the velocity value.

Formula: Fd=(0.5)*rho*Cd*A*v^2

Fd=Drag Force, rho=Density of force, Cd=Coefficient of Drag, A=Frontal Area, v=Velocity of Cyclist

Program

% Program for calculating Drag Force against a cyclist
% Step 1
clear all
close all
clc

% Step 2
% Variables
% Density of air in kg/m^3
rho=1.2;

% Frontal Area in m^2
A=1.2;

% Velocity of cyclist in m/s which is changing from 1 to 10
v=[1:10];

%Coeffient of Drag in m/s which is changing from 0 to 1.8
Cd=[0:0.1:1.8];

% In this program, we will plot Drag Coefficient on X-axis
% & corresponding Drag Force on Y axis
% We will plot many curves with increment value Value

% Drag force applied on Cyclist by air
% Step 3
for i=1:length(v)
    % Step 4
    % To get each curve in different color
    color=[rand rand rand];
    
    % Step 5
    %Basic Formula to calculate Drag Force
    Fd=0.5*rho*A*Cd*(v(i)*v(i));
    
    % Step 6
    %For holding previous curve in for loop
    hold on
    
    % Step 7
    %plotting the curve
    %I am writing Cd(i) to get different thickness for each curve
    plot(Cd,Fd,'linewidth',v(i)*0.2,'color',color)
    
    % Step 8
    %Labelling axis
    xlabel('Drag Coeffient)')
    ylabel('Drag Force (N)')
    
    % Step 9
    %Title for plot
    title('Drag Force against a cyclist');
    
    % Step 10
    %to identify each curve with respect corresponding value of Drag
    %Coefficient
    text{i}=sprintf('%d',v(i));
    legend(text);
    
    % Step 11
    grid on
   
end

Stepwise Explanation

Step 1

Explanation: For clearing command window & workspace, closing all plots.

Step 2

Explanation: Defining variables. I have considered various values of velocity & drag Coefficient by defining Arrays.

Step 3

Explanation: I have used for loop because I want to create various plot for incremental changes in the velocity.

Step 4

Explanation: Defining color variable to get each graph in different colour.

Step 5

Explanation: Used formula for Drag Force.

Step 6

Explanation: Used hold on command to hold previous plot.

Step 7

Explanation: Plotting coefficient of Drag on X axis & Drag Force on Y axis. Used v(i)*0.2 to get increasing thickness of plot with increasing value of v.

Step 8

Explanation: Labelling coefficient of Drag to X axis & Drag Force to Y axis.

Step 9

Explanation: to give title to plot.

Step 10

Explanation: I want to label each curve as per value of Drag Coefficient, hence I have used this new functions ‘sprintf’ & ‘legend’

Step 11

Explanation: To turn on grid.

Error & Solution: I want to show valve of v (Velocity) for each curve but I am unable to do it. I have tried many methods. Finally, by discussing this issue with Skill Lync expert, I have decided to use legend command. For that I used sprint command & store valve of v(i) in cell array by using text{i}. Below you can see previous plot & revised plot.

Previous Plot & Revised Plot

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.