MATLAB: Ploting 3d constrains

constrains

Hey, i am new to matlab and i want to plot 3d the constrains of an objective function.The constrains are 20000=<x=<40000,0=<y=<40000,0=<z=<40000, and x+y+z=90000.I want to plot it and get a plane for X=20000.Is there any similar code to work on it ?

Best Answer

Here is my proposition:
[x,y] = meshgrid(20000:400:40000,0:800:40000);
z = 90000-x-y;
z(z>40000 | z<0) = NaN;
surf(x,y,z,'facecolor','none')
hold on
idx = x==20000;
plot3(x(idx),y(idx),z(idx),'r','LineWidth',2)
xlabel('x');ylabel('y');zlabel('z')