Connecting 2D ellipses in a 3D plot to make a 3D 'tunnel'
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Thomas Swain
le 29 Fév 2020
Commenté : Star Strider
le 29 Fév 2020
Hi all,
I have produced a 3D plot which shows the mean trace of a number of movements. I have also come up with an 'error band' using a number of ellipses (see attached figure).
While this is suitable for the desired application, I think that if I can connect the ellipses and produce a semi-transparent 'tunnel', this would look far better.
The code I used to produce the plot in the figure is as follows:
hold off
plot3(x_mean_origin,y_mean_origin,z_mean_origin,'r','LineWidth',3)
hold on
for i=1:1:100
a=stddevmax_smooth(i);
b=zstddev(i);
x=a*cos(theta)+x_mean_origin(i);
y=zeros(1,numel(x))+y_mean_origin(i);
z=b*sin(theta)+z_mean_origin(i);
rotate(plot3(x,y,z,'m'),[0 0 1],phi(i),[x_mean_origin(i) y_mean_origin(i) z_mean_origin(i)]);
end
I am aware of functions such as 'fill' and 'surf' and 'mesh', but not really sure how to incorporate them in this instance. I'm hoping it is fairly straightforward, so any support you can provide is greatly appreciated! Also I have only supplied a small section of my code, so if any more is required for context, just let me know.
Many thanks!
0 commentaires
Réponse acceptée
Star Strider
le 29 Fév 2020
I am not certain what you want.
Try this:
F = openfig('Mean throw with 1SD error band.fig');
Ax = findobj(F,'Type','Axes');
D = findobj(F,'Type','line');
Q2 = D(50);
for k = 1:numel(D)
X(k,:) = D(k).XData;
Y(k,:) = D(k).YData;
Z(k,:) = D(k).ZData;
end
figure
hs = surf(X, Y, Z)
set(hs, 'EdgeColor','none', 'FaceAlpha', 0.5)
grid on
producing:
Experiment to get the result you want. See Surface Properties to understand options for surf plots to get it to look the way you want it to look.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!