1. A solid sphere of radius r and density p, is placed in a fluid of density po.
ID: 3308087 • Letter: 1
Question
1. A solid sphere of radius r and density p, is placed in a fluid of density po. The sphere sinks to a depth of h. The volume of sphere below the fluid surface is . Develop a MATLAB function to calculate h based on input values r, ps and po. Your function should prompt a user to input r, ps and po and print the output as The sphere depth below the fluid surface is:'. Test your code with r=40mm, ps-0.6 ghnm3 and po =1.0 ghnm3. Next, develop a function that calculates the ratio h/r for a given (p/po) ratio. Plot the graph of h/r vs. (p/po). Discuss the results using your knowledge of engineering and Physics. (25 marks)Explanation / Answer
Please run the codes seperately
1) To calculate h
prompt = 'enter r ';
r = input(prompt);
prompt = 'enter rhos ';
rhos = input(prompt);
prompt = 'enter rhonot ';
rhonot = input(prompt);
a=1;
b=-3*r;
c=0;
d=4*r^3*rhos/rhonot;
p=[a,b,c,d];
h=roots(p);
h
2)To calculate ratio h/r
prompt = 'enter rho ratio ';
rhoratio = input(prompt);
a=1;
b=-3;
c=0;
d=4*rhoratio;
p=[a,b,c,d];
hrratio=roots(p);
hrratio
3)to plot the required graph
for k=1:100
rhoratio=k*0.1;
a=1;
b=-3;
c=0;
d=4*rhoratio;
p=[a,b,c,d]
hrratio=max(roots(p));
matrx=zeros(1,100);
matrx(1,k)=rhoratio;
matry=zeros(1,100);
matry(1,k)=hrratio;
end
plot(matrx,matry)
The graph is a straight line.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.