this script optimizes the cheapest cost for an open top rectangular box it works fine until i display the cheapest cost of a box but when i try to use the length ,width and height of the box to plot its 3d diagram of a box it throws an error that " Error using patch Vectors must be the same length."
regards.
%% Cheapest Price for Rectangular Box
%%
vol=input('Enter volume of box : ');syms l x h positiveeqn=10*2*x*x+12*2*x*(vol/(2*x*x))+12*(vol/(2*x*x))*x;seceqn=diff(eqn);width=solve (seceqn==0,x);l=2*width;h=vol/(l*width);cost=10*2*width*width+12*2*width*(vol/(2*width*width))+12*(vol/(2*width*vol))*vol;cost=double(cost);disp('Cheapest Cost is = ');disp(cost);patch([0,l,l,0],[0,0,width,width],[0,0,0,0],'blue')patch([0,l,l,0],[0,0,0,0],[0,0,h,h],'red')patch([0,l,l,0],[width,width,width,width],[h,h,0,0],'green')patch([0,0,0,0],[0,0,width,width],[0,h,h,0],'black')patch([l,l,l,l],[0,0,width,width],[h,0,0,h],'yellow')
Best Answer