How to Graph with the endpoints excluded from values
4 次查看(过去 30 天)
显示 更早的评论
I have a cost to radius problem involving a water tower with a cylinder bas and a hemispherical top. The problem asks to plot the total cost of building the water tower with 2<r<10, with 2 and 10 not being included, in an interval of 0.01 to account for pennies in the cost. Here is my current process:
Equations listed in the problem
% r = 2:0.01:10;
% sa_of_cylinder = 2*pi*r*h;
% volume_of_cylinder = pi*r^2*h;
% sa_of_top = 2*pi*r.^2;
% volume_of_top = (2*pi*r.^3)/3;
% Cost_Cylinder = 300*sa_of_cylinder;
% Cost_Top = 400*sa_of_top;
% V_total = 500
% Find the radius that results in the least cost
% Cost_total = Cost_Cylinder + Cost_Top;
%
% Cost_total = 300*2*pi*r*h + 400*2*pi*r^2
%
% V_total = volume_of_top + volume of Cylinder
% 500 = volume_of_top + pi*r^2*h
% h = (500 - volume_of_top)/(pi*r^2)
%
% Substitute h back into the cost total
%
% Cost_total = ((600*pi*r)*((500-volume_of_top))/(pi*r^2) + Cost_Top
r = (2:0.01:10);
volume_of_top = (2*pi*r.^3)/3;
Cost_Top = 800*pi*r.^2;
Cost_total = 600*pi*r*((500-volume_of_top)/(pi*r.^2)) + Cost_Top;
plot(r,Cost_total)
xlabel('r = radius')
ylabel('Total Cost')
legend('Total Cost for Radius')
grid on
title('Cost of Building a Water Tower of Differing Radii')
According to the code, the minimum cost is associated with a radius of 2, but i dont want to have r=2 be an option. I am not even sure my graph is correct, for all i know i got it wrong. I just need someone with a greater understanding of Matlab to test the process and plot for the minimum cost and associated radius, or tell me what part of the code i got wrong.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!