title: Hoe can I view the skeleton in 3D coordinate system in matlab
body: <p>I have the following code in matlab which save the pics of each position that the skeleton at, but it displayed as a skeleton in 2D coordinate system.</p>
  
  <p>In order to better use the data, I want to make the skeleton view in 3D coordinate system.
  Here is the code that I am running, could anybody tell me how to make is possible?</p>
  
  <pre><code>&gt;&gt; for j=1:size(JointLocation_3D,1)
      for jointNum=1:14
      XL(1,jointNum)= JointLocation_3D(j,jointNum*3-2);
      XL(2,jointNum)=JointLocation_3D(j,jointNum*3-1);
      XL(3,jointNum)=JointLocation_3D(j,jointNum*3);
      end
  
      h=figure(j);
      i=1;
      x_leg = XL(1,i*14-13:i*14-8);
      y_leg = XL(2,i*14-13:i*14-8);
      z_leg = XL(3,i*14-13:i*14-8);
      line(x_leg,y_leg,z_leg,...
          'Marker', 'o',...
          'Color','r',...
          'LineWidth',5,...
          'MarkerSize',8,...
          'MarkerEdgeColor','b',...
          'MarkerFaceColor','b');
      hold on
  
      %arms and shoulders
      x_arm_right = XL(1,i*14-7:i*14-5);
      y_arm_right = XL(2,i*14-7:i*14-5);
      z_arm_right = XL(3,i*14-7:i*14-5);
      line(x_arm_right,y_arm_right, z_arm_right,...
          'Marker', 'o',...
          'Color','r',...
          'LineWidth',5,...
          'MarkerSize',8,...
          'MarkerEdgeColor','b',...
          'MarkerFaceColor','b');
      hold on;
  
      x_arm_left = XL(1,i*14-4:i*14-2);
      y_arm_left = XL(2,i*14-4:i*14-2);
      z_arm_left = XL(3,i*14-4:i*14-2);
      line('XData',x_arm_left,'YData',y_arm_left, 'ZData',z_arm_left,...
          'Marker', 'o',...
          'Color','r',...
          'LineWidth',5,...
          'MarkerSize',8,...
          'MarkerEdgeColor','b',...
          'MarkerFaceColor','b');
      hold on;
  
      line('XData',[XL(1,i*14-5); XL(1,i*14-1); XL(1,i*14-4)],...
          'YData',[XL(2,i*14-5); XL(2,i*14-1); XL(2,i*14-4)],...
          'ZData',[XL(3,i*14-5); XL(3,i*14-1); XL(3,i*14-4)],...
          'Marker', 'o',...
          'Color','r',...
          'LineWidth',5,...
          'MarkerSize',8,...
          'MarkerEdgeColor','b',...
          'MarkerFaceColor','b');
      hold on;
  
      mid_point = [mean(XL(1,i*14-11:i*14-10));mean(XL(2,i*14-11:i*14-10));mean(XL(3,i*14-11:i*14-10))];
      line('XData', [mid_point(1); XL(1,i*14-1);  XL(1,i*14)],... 
          'YData',[mid_point(2); XL(2,i*14-1);  XL(2,i*14)],...
          'ZData', [mid_point(3); XL(3,i*14-1); XL(3,i*14)],...
          'Marker', 'o',...
          'Color','r',...
          'LineWidth',5,...
          'MarkerSize',8,...
          'MarkerEdgeColor','b',...
          'MarkerFaceColor','b');
    % hold off
     hold on
       figure();
       xlim([-50,350]);
       ylim([-350,350]);    
       zlim([1100, 1700]);
       %axis off;
       axis normal
       grid on;
       %view(3);
       %view(90,30);
       %view(-181,-90);
  
        set(h,'visible','off');
        str=strcat('C:\Program Files\VirtApps\MATLAB\remove',sprintf('3D_%.4d',j),'.jpg');
        saveas(h,str);
   close all
  end
  </code></pre>