% Use % % help plot3 % % to get some documentation on plotting. % % The command % % plot3(x,y,z) % % draws a polygon through the points % (x(1),y(1),z(1)) ,..., (x(n),y(n),z(n)), % where x,y,z are column vectors of length n. % % To get a cube, imagine tracing the edges in sequence % and then put the vertex coordinates into x,y, and z % in the order they are encountered. It is OK to retrace edges. % % The following solution with n=16 retraces 3 edges: % Vertices in the order they are encountered: u = [ 0 0 0; 1 0 0; 1 0 1; 1 1 1; 1 1 0; 0 1 0; 0 1 1; 0 0 1; 0 0 0; 0 1 0; 0 1 1; 1 1 1; 1 1 0; 1 0 0; 1 0 1; 0 0 1; 0 0 0] % Copy columns into x,y,z and plot: x=u(:,1); y=u(:,2); z=u(:,3); plot3(x,y,z)