Hint: The polyfit command finds a polynomial of a specified order that best fits the given data. In this example, we want to see if the experimental data falls along a straight line. We therefore choose 1 as the degree of the polynomial. Hint: The polyfit command returns a vector containing the coefficients of the polynomial: [ ] 1 0 n α α α L corresponding to ( ) 1 1 0 ... n n P X X X α α α = + + + Hint: To suppress the line connecting the experimental data points, select the big arrow in the figure’s menu and double-click on the line. A property editor window will appear. Change the line style to ‘no line’ and choose circles for the marker style. ! SOLUTION close all clear all % Experimental data Re = [0.05875 0.1003 0.1585 0.4786 3.020 7.015]; Cd = [492 256.2 169.8 58.88 10.86 5.5623]; % Take the logarithm of these data lnRe = log(Re); lnCd = log(Cd); % Construct the line that fits best data. As we want a % line, the degree of the polynomial is set to 1. P = polyfit(lnRe,lnCd,1) % Define the fitting line, so it can be plotted lnRefit = linspace(log(0.05875),log(7.015),20); lnCdfit = P(1)*lnRefit + P(2); Re 0.05875 0.1003 0.1585 0.4786 3.020 D C 492 256.2 169.8 58.88 10.86
% Define the theoretical line : ln(Cd) = - ln(Re) + ln(24) lnRetheo = linspace(log(0.05875),log(7.015),20); lnCdtheo = log(24) - lnRetheo; plot(lnRe,lnCd) hold on plot(lnRefit,lnCdfit,'--') plot(lnRetheo,lnCdtheo,'-.') xlabel('ln(Re)') ylabel('ln(Cd)') title('drag coefficient on a sphere as a function of the Reynolds number') grid on P = -0.92980905266427 3.45384753973349 If the experimental data were exactly following Stokes’ law, P would be : Ptheo = -1.0000 3.17805383 The experiment are thus in good agreement with the theory -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 1 2 3 4 5 6 7 ln(Re) ln(Cd) drag coefficient on a sphere as a function of the Reynolds number Experimental data Best fit Theoretical line : YOUR TURN The same students have repeated their experiments at Reynolds numbers between 10 4 and 10 5 and have found a constant drag coefficient of 0.4775. Assume the density of air ρ is 1.25 kg/m 3 . The following table give the drag force on the sphere as a function of the air speed. V (m/s) 4 6 7 8 9 D F (N) 0.036 0.09298 0.10682 0.1568 0.193 Find the radius of the sphere used in the experiments. Follow these steps: a) In the definition of the drag force: 2 2 1 2 D D F C V r ρ π = the group 2 1 2 D C r ρπ is now a constant, since the drag coefficient is assumed to be constant. That means that the plot of D F versus 2 V should be close to a straight line. Using polyfit , find an equation of a line that best fits the data given in the table b) Using the results in part a) extract the value of 2 1 2 D C r ρπ c) Using the numerical values provided, estimate the radius of the sphere 20. Vectors of random numbers Command : randn generate a vector whose components are chosen at random hist plot a histogram
At the assembly line of a big aircraft company, bolts are stored in boxes containing 1000 parts each. The bolts are supposed to have a nominal diameter of 5 millimetres. But due to the uncertainty in the manufacturing process, some turn out to be larger and some turn out to be smaller than nominal.