Create timeseries of a 3d scattered plot
10 ビュー (過去 30 日間)
表示 古いコメント
Hello all,
I have a dataset displayed in a 3D scattered plot superimposed with a closed cylinder.
I wish to plot a time series (movie) showing when each scattered plot point was recorded in the scattered plot.
Below is my interial code:
A = 25*rand(8, 5)
Time = A (:,1) ;
x = A (:,2 ) ;
y = A (:,3 ) ;
z = A (:,4 ) ;
Amplitude = A (:,5) ;
scatter3 (x , y, z, 30, Amplitude);
title ('Sample Material')
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); % capture the handle of the surf object
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)
My current challenge comes from adding the time series. I will be grateful to have some comments on how to proceed.
Here is my additional code for the timespan:
ts1 = timeseries(A (:,1), x,y,z,Amplitude);
ts1.Name = 'Sample Material - Time Span';
ts1.TimeInfo.Units = 'hours';
ts1.TimeInfo.StartTime = '00.00';
ts1.TimeInfo.Format = 'hh mm, ss';
ts1.Time = ts1.Time - ts1.Time(1);
plot(ts1);
Thank you.
採用された回答
Ive J
2022 年 2 月 2 日
If you want to create an animation (GIF for instance) or a movie (e.g. AVI), you can:
% see: https://mathworks.com/matlabcentral/answers/94495-how-can-i-create-animated-gif-images-in-matlab
for i = 1:20
A = 25*rand(8, 5);
Time = A (:,1) ;
x = A (:,2 ) ;
y = A (:,3 ) ;
z = A (:,4 ) ;
Amplitude = A (:,5) ;
scatter3 (x , y, z, 30, Amplitude);
title ('Sample Material')
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); % capture the handle of the surf object
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
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if i == 1
imwrite(imind, cm, 'myanimation.gif', 'gif', 'Loopcount', 1);
else
imwrite(imind, cm, 'myanimation.gif', 'gif', 'WriteMode', 'append');
end
end
Similarly, for a movie:
for i = 1:20
% plot
drawnow
f(i) = getframe(gcf);
end
vidobj = VideoWriter('mymovie.avi');
vidobj.FrameRate = 10;
open(vidobj);
for i = 1:numel(f); writeVideo(vidobj, f(i)); end
close(vidobj);
その他の回答 (0 件)
参考
カテゴリ
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!