| | | p(2) = patch('FaceColor,,,green',,Parent,,t(2)); txt(2) = text('String,,,Right,,,Parent',t(2)); p(3) = patch('FaceColor,,,blue,,,Parent',t(3)); txt(3) = text(,String',,Back,,,Color,,,white,,,Parent,,t(3)); p(4) = patch('FaceColor,,,yellow',,Parent,,t(4)); txt(4) = text('String,,,Top,,,Parent',t(4)); p(5) = patch('FaceColor,,,cyan',,Parent,,t(5)); txt(5) = text('String,,,Left,,,Parent',t(5)); p(6) = patch('FaceColor,,,magenta',,Parent,,t(6)); txt(6) = text('String,,,Front,,,Parent',t(6)); % Set the patch x, y, and z data set(p,'XData',X,,YData,,Y,'ZData',Z) % Set the position and alignment of the text set(txt,'Position',[Xtext Ytext Ztext],... 'HorizontalAlignment','center',... 'VerticalAlignment','middle') 4 Translate the squares (patch objects) to the desired locations. Note that as hgtransform object 2 is translated, all its children (including hgtransform objects 3 through 6) are also translated. Therefore, each translation requires moving the square by only one unit in either the x or y direction. Hgtransform object 1 is left at its original position. % Set up initial translation transform matrices % Translate 1 unit in x Tx = makehgtform('translate',[1 0 0]); % Translate 1 unit in y Ty = makehgtform('translate',[0 1 0]); % Set the Matrix property of each hgtransform object (2-6) set(t(2),'Matrix',Tx); drawnow set(t(3),'Matrix',Ty); drawnow set(t(4),'Matrix',Tx); drawnow set(t(5),'Matrix',Ty); drawnow set(t(6),'Matrix',Tx); | | |