How to animate nested for loop scatter plot?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I'm trying to make an animated figure that refreshes 64pts each frame, it's set to designate a new colorscale for each 64 pts according to amplitude -- I left out the rest of the code as it isn't relevant to plotting. I've tried to mess around with drawnow, erasemode (which I think doesn't exist anymore) and getframe/movie but I'm just not getting what I would like. The data to be plotted is in an 1x64xtimelength and it is arranged according to matrix A. Thanks so much in advance for your help!
% code starts at fill order
end
%%Fill order
A = [1,3;1,5;1,7;
2,2;2,4;2,6;2,8;2,10;
3,1;2,3;3,5;3,7;3,9;3,11;
4,2;4,4;4,6;4,8;3,12;5,8;
5,1;5,3;5,5;11,10;5,12;5,11;
6,2;6,4;6,6;6,8;6,10;6,12;
7,1;7,3;7,5;8,3;7,9;12,9;
8,2;8,4;8,6;8,8;11,2;8,12;
9,1;9,3;9,5;9,7;9,9;9,11;
10,2;10,4;10,6;10,8;10,10;10,12;
11,3;11,5;11,7;11,9;11,11;
12,6;12,8;12,10;];
% makes a 64 pt colormap (jet scale) BB = reshape(B,1,64,length(B));
%downsize data for testing purposes BB=BB(:,:,400:500);
c = colormap(jet(64)); hold on
for jj = 1:length(B);
% below sorts reshaped max/min values of each period so each half
% period shows up as color scaled based on 64 pt colormap
[~,Index]=sort(BB(1,1:end,jj),'descend');
D=zeros(64,2);
%
for i=1:64
x = Index(i);
C = A(x,:);
D(i,:)=C;
end
for ii = 1:64
plot3(D(ii,1),D(ii,2),BB(1,ii,jj),'Color',c(ii,:),'Marker','.','MarkerSize',25);
axis([0,12,0,12,-1.1,1.1]);
view([-40,20]);
%drawnow limitrate
%pause(0);
end
drawnow
EraseMode
% M(jj)=getframe;
% frame2in
% drawnow
% clf;
end
% figure
% movie (M,100)
Antworten (0)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!