diff --git a/README.md b/README.md index 250460b..17c04bd 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ ME 3255 Homework 5 ##Problem 2 + Least Squares function ```matlab function [a,fx,r2] = least_squares(Z,y); @@ -159,6 +160,14 @@ Output: - L = 5.0108 m #Problem 5 ###Part A +```matlab +cd_out_linear = sphere_drag(300,'linear') = 0.1750 +cd_out_spline = sphere_drag(300,'spline') = 0.1809 +cd_out_pchip = sphere_drag(300,'pchip') = 0.1807 +``` + +### Part B +![Drag Force vs. Velocity (3 Interpolation Methods)](./figure5.png) #Problem 6 ###Analytical @@ -190,7 +199,7 @@ tildex = (b-a)/2*x + (b+a)/2; f = (1/6).*(tildex).^3+(1/2).*(tildex).^2+(tildex); value2 = sum(tildec.*f) ``` -###3-point +##3-point ```matlab %Three Point x = [-0.77459666,0,0.77459666]; diff --git a/figure5.png b/figure5.png new file mode 100644 index 0000000..61658e6 Binary files /dev/null and b/figure5.png differ diff --git a/sphere_drag.m b/sphere_drag.m index e75818f..204b485 100644 --- a/sphere_drag.m +++ b/sphere_drag.m @@ -1,10 +1,26 @@ function [Cd_out] = sphere_drag(Re_in,spline_type) % interpolation for drag coeff based upon Reynolds number - % output is + % output is % Cd: drag coeff - % input is + % input is % Re_in: Reynolds number - % and + % and % spline_type: 'linear', 'cubic', or 'spline'/'pchip' - - \ No newline at end of file + + %function [Cd_out]=sphere_drag(Re_in,spline_type) + data = [2 0.52 + 5.8 0.52 + 16.8 0.52 + 27.2 0.5 + 29.9 0.49 + 33.9 0.44 + 36.3 0.18 + 40 0.074 + 46 0.067 + 60 0.08 + 100 0.12 + 200 0.16 + 400 0.19]; + + Cd_out = interp1(data(:,1),data(:,2),Re_in,spline_type); +end