MATLAB Problem. Please provide detail A fuel tank is made of a half cylinder (r
ID: 3799911 • Letter: M
Question
MATLAB Problem. Please provide detail 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 2r h - h^2] in^3 times gallon/231 in^3 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
% matlab code
r = 14;
% height ranging from 0 to 14 with incrmenets of 2 inches
h = linspace(0,14,8);
disp(h);
Vfuel = [];
% applying the formula
for i=1:length(h)
x = r*r*acos((r-h(i))/h(i));
s = sqrt(2*r*h(i)-h(i)*h(i));
y = (r-h(i))*s;
Vfuel(i) = 36*(x-y)/231;
end
disp('Vfuel');
disp(Vfuel);
% end matlab code
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.