1
function [dv_dt] = homework_1(m,g,C_D,p_air,d,V,t) dv_dt = -g - (1/(2*m))*C_D*p_air*((pi/4)*(d^2))*V*abs(V); end TSPAN = [0 5]; % Time span V0 = 0; % Initial velocity p_air = 1.2; % Density of air p_water = 1000; % Density of pure water since SG_air = p_air/p_water d = 0.01; % Diameter of the sphere SG = 2.6; % Specific gravity of the sphere m = SG*p_water*(4/3)*pi*((d/2)^3); % Computing mass of the sphere g = 9.81; % Gravity constant C_D = 0.8; % Coefficient of drag A = pi*(d^2)/4; % Cross sectional area of the sphere fun = @(t,V)homework_1(m,g,C_D,p_air,d,V,t); [TOUT, VOUT] = ode45(fun, TSPAN, V0); plot(TOUT,VOUT); xlabel('Time'); ylabel('Velocity'); V_Final = -18.82 % Extended TSPAN to [0 30] and found what value velocity stabilized at V_99 = 0.99*V_Final % Calculated 99% of terminal velocity & found what row in VOUT held the value closest to V_99 T_Final = 5.175 % Looked at TOUT and found the value in the same row as the terminal velocity found in VOUT

CEE 170 UCI Homework 1 Matlab

Embed Size (px)

DESCRIPTION

MATLAB portion of UCI CEE 170 Homwork #1

Citation preview

Page 1: CEE 170 UCI Homework 1 Matlab

function [dv_dt] = homework_1(m,g,C_D,p_air,d,V,t) dv_dt = -g - (1/(2*m))*C_D*p_air*((pi/4)*(d^2))*V*abs(V); end

TSPAN = [0 5]; % Time spanV0 = 0; % Initial velocityp_air = 1.2; % Density of airp_water = 1000; % Density of pure water since SG_air = p_air/p_waterd = 0.01; % Diameter of the sphereSG = 2.6; % Specific gravity of the spherem = SG*p_water*(4/3)*pi*((d/2)^3); % Computing mass of the sphereg = 9.81; % Gravity constantC_D = 0.8; % Coefficient of dragA = pi*(d^2)/4; % Cross sectional area of the sphere fun = @(t,V)homework_1(m,g,C_D,p_air,d,V,t); [TOUT, VOUT] = ode45(fun, TSPAN, V0);plot(TOUT,VOUT);xlabel('Time');ylabel('Velocity'); V_Final = -18.82 % Extended TSPAN to [0 30] and found what value velocity stabilized atV_99 = 0.99*V_Final % Calculated 99% of terminal velocity & found what row in VOUT held the value closest to V_99T_Final = 5.175 % Looked at TOUT and found the value in the same row as the terminal velocity found in VOUT