Cube Plot
X=linspace(-1,1,101); % Define point on x axis
Y=ones(size(X)); % define points of y axis
Z=Y;% define point on z axis
%%SURFACE AT Z=1
plot3([X fliplr(X)], [Y (-1*Y)], [Z (Z)],'r')
xlabel('X')
hold on
%%SURFACE AT Z=-1
plot3([X fliplr(X)],[Y (-1*Y)],[(-1*Z) (-1*Z)],'b')
xlabel('X')
hold on
%%SURFACE AT Y=1
plot3([X fliplr(X)], [Y Y], [Z (-1*Z)], 'k')
ylabel('Y')
hold on
%%SURFACE AT Y=-1
plot3([X fliplr(X)],[(-1*Y) (-1*Y)], [Y (-1*Y)], 'y')
ylabel('Y')
hold on
%%SURFACE AT X=1
plot3([Z Z], [Y (-1*Y)],[X fliplr(X)], 'm')
zlabel('Z')
hold on
%%SURFACE AT X=-1
plot3([(-1*Z) (-1*Z)], [Y (-1*Y)],[X fliplr(X)], 'c')
zlabel('Z')
hold off
grid
Cube Patch
X=linspace(-1,1,101); % Define point on x axis
Y=ones(size(X)); % define points of y axis
Z=Y;% define point on z axis
figure
%%SURFACE AT Z=1
patch([X fliplr(X)], [Y (-1*Y)], [Z (Z)],'r')
xlabel('X')
hold on
%%SURFACE AT Z=-1
patch([X fliplr(X)],[Y (-1*Y)],[(-1*Z) (-1*Z)],'b')
xlabel('X')
hold on
%%SURFACE AT Y=1
patch([X fliplr(X)], [Y Y], [Z (-1*Z)], 'k')
ylabel('Y')
hold on
%%SURFACE AT Y=-1
patch([X fliplr(X)],[(-1*Y) (-1*Y)], [Y (-1*Y)], 'y')
ylabel('Y')
hold on
%%SURFACE AT X=1
patch([Z Z], [Y (-1*Y)],[X fliplr(X)], 'm')
zlabel('Z')
hold on
%%SURFACE AT X=-1
patch([(-1*Z) (-1*Z)], [Y (-1*Y)],[X fliplr(X)], 'c')
zlabel('Z')
hold off
grid
view(40,40)