Incremental display of data points in a 3D scattered plot
조회 수: 6 (최근 30일)
이전 댓글 표시
Dear all,
I have with me the attached dataset which I will like to display by a gradual representation (accumulation of the plot points in a point by point format until all plot points are displayed) in a scattered plot.
Below here is my code:
%clear all;
%close all;
clc
A = load ('TimespanTutorial.txt');
Time = A (:,1) ;
x = A (:,2 ) ;
y = A (:,3 ) ;
z = A (:,4 ) ;
Amplitude = A (:,5) ;
scatter3 (x , y, z, 30, Amplitude);
title ('TimespanTutorial')
xlim ([-50.00 50.00])
ylim ([-50.00 50.00])
zlim ([0.00 100.00])
xlabel ('Breath /m')
ylabel ('Width /m')
zlabel ('Height /m')
pbaspect([1 1 2])
H = colorbar ;
ylabel (H, 'Amplitude')
hold on
r = 25.000;
[X,Y,Z] = cylinder(r);
hsurf = surf (X,Y,Z*100, 'EdgeColor', 'none', 'FaceAlpha', 0.2);
patch(X(1,:),Y(1,:),Z(1,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
patch(X(1,:),Y(1,:),Z(2,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
hold off
drawnow
for i = 1:A (:,1)
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if i == 1
imwrite(imind, cm, 'myanimation.gif', 'gif', 'Loopcount', 100);
else
imwrite(imind, cm, 'myanimation.gif', 'gif', 'WriteMode', 'append');
end
end
My results show all the plot points in the graph accurately but not in an incremental sequence as desired.
Is there any possibilty that I may get some assitance?
I am open to saving the incremental display of the plot points as photos to create a short movie afterwards.
댓글 수: 0
채택된 답변
Mathieu NOE
2022년 3월 22일
hello
this would be my suggestion
adapt the amount of pause to your needs
all the best
clc
A = load ('TimespanTutorial.txt');
Time = A (:,1) ;
x = A (:,2 ) ;
y = A (:,3 ) ;
z = A (:,4 ) ;
Amplitude = A (:,5) ;
scatter3 (x(1) , y(1), z(1), 30, Amplitude(1));
title ('TimespanTutorial')
xlim ([-50.00 50.00])
ylim ([-50.00 50.00])
zlim ([0.00 100.00])
xlabel ('Breath /m')
ylabel ('Width /m')
zlabel ('Height /m')
pbaspect([1 1 2])
H = colorbar ;
ylabel (H, 'Amplitude')
hold on
r = 25.000;
[X,Y,Z] = cylinder(r);
hsurf = surf (X,Y,Z*100, 'EdgeColor', 'none', 'FaceAlpha', 0.2);
patch(X(1,:),Y(1,:),Z(1,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
patch(X(1,:),Y(1,:),Z(2,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
% gif first frame export
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind, cm, 'myanimation.gif', 'gif', 'Loopcount', numel(Amplitude));
for ci = 2:numel(Amplitude)
scatter3 (x(ci) , y(ci), z(ci), 30, Amplitude(ci));
pause(0.25);
drawnow
% gif remaining frames export
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind, cm, 'myanimation.gif', 'gif', 'WriteMode', 'append');
end
hold off
댓글 수: 5
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!