How can you rotate 3D subplots individually?

5 views (last 30 days)
In the following program snippet, I have two sets of data, X1 and X2. Both are matrices with 3 rows corresponding to X, Y, and Z points for their data sets. I am plotting both matrices in 3D and trying to display both sets in a single figure using subplots. I would like to slowly rotate these subplots since the data can be hard to look at in 2D. How can I accomplish this? I have tried using view, but this only changes the view of the second plot, no matter where I put it in my for loop. Is there a way to rotate plots using set? Thanks in advance.
R = 1;
A = 1;
Handle(1,1) = subplot(2,2,1);
Handle(1,2) = plot3(X1(1,A:R),X1(2,A:R),X1(3,A:R),'Color','r','LineWidth',0.25);
Handle(2,1) = subplot(2,2,2);
Handle(2,2) = plot3(X2(1,A:R),X2(2,A:R),X2(3,A:R),'Color','y','LineWidth',0.25);
for K = BeginTime:TimeStep:EndTime
set(Handle(1,2),'XData',X1(1,A:R),'YData',X1(2,A:R),'ZData',X1(3,A:R));
set(Handle(2,2),'XData',X2(1,A:R),'YData',X2(2,A:R),'ZData',X2(3,A:R));
R = R + 1;
%View here only effects subplot(2,2,2)
view(R,10);
end

Answers (1)

Walter Roberson
Walter Roberson on 13 May 2015
view(Handle(1,2), [R, 10]);
view(Handle(2,2), [R, 10]);
  2 Comments
Daniel Mullen
Daniel Mullen on 13 May 2015
Thank you, that makes sense. Is there any way to do it with set?
Walter Roberson
Walter Roberson on 13 May 2015
Edited: Walter Roberson on 13 May 2015
set(Handle1(1,2), 'View', [R 10]);
set(Handle1(2,2), 'View', [R 10]);
or you could combine these into
set(Handle1(1:2,2), 'View', [R 10]);

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!