Numerical Analysis MATLAB Any code for this problem would be
Numerical Analysis- MATLAB
Any code for this problem would be great.
It is desired to determine the diameter of a glass sphere (Psph-2.6 g/cm) to four significant figures accuracy that will have a terminal velocity of 30 cm/s in an organic liquid with a density (p) of 1.6 g/cm3. The terminal velocity is given by 3f where g is the acceleration of gravity (9.80 m/2) and f is the friction factor, which is a dimensionless quantity that is a function of the Reynolds number (Re-Du/). If Re 103, 1Inc:n :0. M· \'Ihe vi uncily r) of the irra ic liquid is 0.0096 g/cm-s. Use at least two methods to confirm that the approxiated solution is accurate.Solution
Here the friction factor is taken constant 0.44 because the velocity value is not specified in the problem. Otherwise we can check the value of reynolds number for friction factor. The diameter is calculated using Newton Raphson method in MATLAB.
%%MATLAB CODE%%
%CALCULATION OF DIMETER USING NEWTON RAPHSON METHOD
%Density of Sphere
rhosph=2.6;
%Density of Organic Fluid
rho=1.6;
%Terminal Velocity
vt=30;
%Acceleration due toGravity
g=9.8;
%Friction Factor
f=0.44;
%Viscosity
mu=0.0096;
%Initial Value
d=0.05;
dnew=1;
%Newton Raphson Iteration
for i=1:1:100
F=(vt*vt)-(((4*g*d)*(rhosph-rho))\\(3*f*rho));
dF=-((4*g)*(rhosph-rho))\\(3*f*rho);
dnew=d-(F\\dF);
d=dnew;
end
sol=d;
fprintf(\'Approximate Root is %0.4f\', sol);
d=0.05;
dnew=1;
er(5)=0;
%Error Calculation
for i=1:1:5
F=(vt*vt)-(((4*g*d)*(rhosph-rho))\\(3*f*rho));
dF=-((4*g)*(rhosph-rho))\\(3*f*rho);
dnew=d-(F\\dF);
d=dnew;
er(i)=dnew-sol;
end
plot(er);
xlabel(\'No.of iterations\');
ylabel(\'error\');
title(\'Error Vs. No of iterations\');
