Connecting 2D ellipses in a 3D plot to make a 3D 'tunnel'

조회 수: 2 (최근 30일)
Thomas Swain
Thomas Swain 2020년 2월 29일
댓글: Star Strider 2020년 2월 29일
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!

채택된 답변

Star Strider
Star Strider 2020년 2월 29일
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
Thomas Swain
Thomas Swain 2020년 2월 29일
This is exactly what I was hoping for. Thank you so much!!
Star Strider
Star Strider 2020년 2월 29일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by