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!