MATLAB plot moving data points in seperate subplots simutaneously

Posted by Nate B. on Stack Overflow See other posts from Stack Overflow or by Nate B.
Published on 2012-11-19T20:46:29Z Indexed on 2012/11/19 23:02 UTC
Read the original article Hit count: 261

Filed under:
|
|

I wish to visualize the movement of a data point throughout space across a period of time within MATLAB. However, the way I want my figure to display is such that only a single instant is plotted at any given time. That was easy, I simply created a for loop to update my 3D plot display for every set of coordinates (x,y,z) in my data. However, I wish to display 4 different viewing angles of this plot at all times. I am well aware of how to setup subplots within MATLAB, that is not the issue. My issue is getting all 4 of these subplots to execute simultaneously so that all 4 subplots are always displaying the same point in time.

I would appreciate if anyone could suggest how to handle this issue.

As requested, my code for a figure with a single plot is shown below:

datan = DATA; %data in form of x,y,z,a,b,c by column for row# of time points

tib=zeros(size(datan,1),12);
tib(:,1:3) = datan(:,1:3);
tib_ref=tib(1,1:3);

for i=1:size(datan,1)
tib(i,1:3)=tib(i,1:3)-tib_ref;
end

angle_to_dircos

close all

figure('Name','Directions (Individual Cycles)','NumberTitle','off')

for cc=1:2
    hold off
    for bb=1:10:size(tib,1);
    scatter3(tib(bb,1),tib(bb,2),tib(bb,3),'green','filled'); %z and y axes are flipped in polhemus system
    hold on
       p0 = [tib(bb,1),tib(bb,2),tib(bb,3)]; 
       p1 = [tib(bb,1)+10*tib(bb,4),tib(bb,2)+10*tib(bb,5),tib(bb,3)+10*tib(bb,6)]; 
       p2 = [tib(bb,1)+10*tib(bb,7),tib(bb,2)+10*tib(bb,8),tib(bb,3)+10*tib(bb,9)];
       p3 = [-(tib(bb,1)+100*tib(bb,10)),-(tib(bb,2)+100*tib(bb,11)),-(tib(bb,3)+100*tib(bb,12))];      
       vectarrow(p0,p1,1,0,0)
       hold on
       vectarrow(p0,p2,0,1,0)
       hold on
       vectarrow(p0,p3,0,0,1)
       hold on
    az = 90;
    el = 0;
    view(az, el);
    xlim([-50,50]);
    ylim([-50,50]);
    zlim([-50,50]);
    xlabel('distance from center in X');
    ylabel('distance from center in Y');
    zlabel('distance from center in Z');
    title('XYZ Scatter Plots of Tracker Position');
    hold on
    plot3(0,0,0,'sk','markerfacecolor',[0,0,0]);
       p0 = [0,0,0]; 
       p1 = [10,0,0]; 
       p2 = [0,10,0];
       p3 = [0,0,100];      
       vectarrow(p0,p1,1,0,0)
       hold on
       vectarrow(p0,p2,0,1,0)
       hold on
       vectarrow(p0,p3,1,0,1)
    drawnow;
end
end

© Stack Overflow or respective owner

Related posts about matlab

Related posts about plot