A fuel tank is made of a half cylinder (r = 14 in.) as shown. The amount of fuel
ID: 3858546 • Letter: A
Question
A fuel tank is made of a half cylinder (r = 14 in.) as shown. The amount of fuel in gallons as a function of h is given by V_fuel = 36 [r^2 cos^-1 (r - h/r) - (r - h) Squareroot 2 rh - h^2] rightarrow gallon/231 Write a script file that creates a vector for h ranging from 0 to 14 in. with increments of 2 in. Then it calculates the corresponding volume rounded to the nearest tenth of a gallon. The results must be displayed in a two-column table format where the first column is the values of h and the second column is the associated values of the volume of fuel in the tank (in gallons). Save your results to an ASCII format data file with the name Lab4Prob1.txt that can be read by MATLAB or a text-editor on virtually any platform.Explanation / Answer
volume = @(r,h) 36*((r^2)*acos(1 - h/r) - (r-h)*sqrt(2*r*h-h*h));
fileID = fopen('Lab4Prob.txt','w');
r = 14;
for h = 0:2:14
fprintf(fileID,'%d %d ',h,volume(r,h))
end
fclose(fileID);
Pleae note that am having trouble understanding the volume formula... Please verify it. If am incorrect, please let me know the correct formula.. else I shall investigate. Apart form that I hope you will like the code!
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.