In: Mechanical Engineering
A water tank consists of a cylindrical part of radius r and height h and a hemispherical top. The tank is to be constructed to hold 600 m3 when filled. The surface area of the cylindrical part is 2πrh, and its volume is πr2h. The surface area of the hemispherical top is given by 2πr2, and its volume is given by 2πr3/3. The cost to construct the cylindrical part of the tank is $400 per square meter of surface area; the hemispherical part costs $600 per square meter. Use the fminbnd function to compute the radius that results in the least cost. Compute the corresponding height h.
Program plan:
• Write a function having two arguments height and the total cost of constructions as the function of radius.
• ‘fminbnd’ is used to find the least value of the function between the given intervals.
Program:
%**********************************************************
%A function is declared for the total cost and height as
%the arguments and the radius as the variable, fminbnd is
%used to find the radius of the least cost.
%**********************************************************
%function of radius
function [totalcost,height]=tc(r)
%‘height’ and ‘totatcost’ are the variables declared in the function.
height=600./(pi.*r.^2)-2.*r./3;
totalcost=2.*pi.*r.*height.*400+2.*pi.*600.*r.^2;
end
%main program
%‘fminbnd’ is used to find the minimum value of the function in the given interval.
rmin=fminbnd(@tc,0,10);
%‘rmin’ is assigned with the radius corresponding to the minimum total cost
disp('The radius which has least total cost is ');
%displays rmin value
disp(rmin);
%This line is used to call the function and assign the values of total cost and height to ‘[t,h]’
[t,h]=tc(rmin);
%displays 'Total minimum cost' text
disp('Total minimum cost');
%displays t variable value
disp(t);
%displays text
disp('The corresponding height is ');
%displays h variable value
disp(h);
Output:
The radius which has least total cost is 4.8572.
Total minimum cost 1.4823e+05.
The corresponding height is 4.8572.