MATLAB problem Would like detail The pressure drop delta p i
MATLAB problem. Would like detail
 The pressure drop delta p in Pa for a fluid flowing in a pipe with a sudden increase in diameter is given by:  delta p = 1/2[1 - (d/D)^2]^2 rho v^2  where rho is the density of the fluid, v, the velocity of the flow, and d and D are defined in the figure. Write a program in a script file that calculates the pressure drop delta p. When the script file is executed it requests the user to input the density in kg/m^3, the velocity in m/s, and values of the non-dimensional ratio d/D as a vector. The program displays the inputted values of rho and v followed by a table with the values of d/D in the first column and the corresponding values of delta p in the second column. Use format g in fprintf () to display the table.  Execute the program assuming flow of gasoline (rho = 737 kg/m^3) at v = 5 m/s and the following ratios of diameters.  d/D = 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3.Solution
 prompt = \'enter density in kg/m^3 \';
 p = input(prompt);
prompt = \'enter velocity in m/s \';
 v = input(prompt);
 ratios =[];
 cnt = 1;
while 1 %ask the user ratios and when user enters 0 stop
   
 x = input(\'enter ratios and when done enter 0 \');
 if(x==0)
 break;
 end
 ratios(cnt)=x;
 cnt = cnt+1;
end
 deltap=[];
%compute deltap for given ratios and store it in vector deltap
for t = 1:length(ratios)
   
deltap(t)=0.5*(1-(ratios(t))^2)^2*p*v^2;
   
 end
%convert deltap and ratiso into an array with rows=columns i.e number of
 %ratiso and columns=row i.e 1
 deltap=reshape(deltap,[length(ratios),1]);
 ratios=reshape(ratios,[length(ratios),1]);
%convert deltap and ratios into a table and display it
 T=table(deltap,ratios)

