Create timeseries of a 3d scattered plot
Mostra commenti meno recenti
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.
4 Commenti
Simon Chan
il 2 Feb 2022
Simply using a for loop and a pause may create a movie-like presentation.
Try the following to see whether this is what you want.
for k = 1:10
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);
ax = gca;
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(ax,'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);
pause(1);
hold(ax,'off');
end
Greek McCoy
il 2 Feb 2022
Simon Chan
il 2 Feb 2022
Modify slightly and let see the following is what you want? You may use this as the starting point.
for k = 1:10
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);
ax = gca;
if k == 1
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(ax,'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);
else
pause(1);
end
end
Greek McCoy
il 3 Feb 2022
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Graphics Object Properties in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
