필터 지우기
필터 지우기

How to Revolve a 2D Profile and Make it's 3D Plot

조회 수: 5 (최근 30일)
Mahmoud Abbas
Mahmoud Abbas 2022년 4월 12일
답변: mark li 2022년 4월 12일
Hello, i am trying to figure out how to revolve this profile around any axis (lets assume x=35) and make the plot in 3D. I found a really good solution here (https://www.mathworks.com/matlabcentral/answers/522502-how-can-i-revolve-a-2d-plot-by-2pi-around-an-axis-to-make-a-3d-surface-plot) but i am having trouble applying to this simple code
x = [82,80,65,38,82]
y = [82,54,36,94,82]
plot(x,y)

채택된 답변

mark li
mark li 2022년 4월 12일
This is a example:
x = [82,80,65,38,82];
y = [82,54,36,94,82];
x_zero = 35;
theta = linspace(0,2*pi,100);
X = [];
Y = [];
Z = [];
for i = 1 : length(x)
X_new = sin(theta)*(x(i)-x_zero)+x_zero;
Y_new = cos(theta)*(x(i)-x_zero)+x_zero;
Z_new = y(i)*ones(1,100);
X = [X ; X_new];
Y = [Y ; Y_new];
Z = [Z ; Z_new];
end
surface(X, Y , Z)
You may modify x and y, and the function surface may not be appropriate!

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by