clc; clear
x0 = [ 1 1 1]';
A = []; b = []; Aeq = []; beq = []; lb = []; ub = [];
xmin = fmincon(@S,x0,A,b,Aeq,beq,lb,ub,@bincon);
r = xmin(1);
hcyl = xmin(2);
hcon = xmin(3);
fprintf('\nradius = %4.2f m\n',r);
fprintf('cylinder height = %4.2f m\n',hcyl);
fprintf('cone height = %4.2f m\n',hcon);
phi = atan(r/hcon);
phid = rad2deg(phi);
fprintf('cone angle = %4.1f deg\n',phid);
fprintf('surface area = %6.1f m2\n',S(xmin));
fprintf('volume = %6.1f m3\n',V(xmin));

