3D Plot from finite 2D Plots in each section!

조회 수: 1 (최근 30일)
Hossein
Hossein 2015년 9월 18일
답변: emehmetcik 2015년 9월 18일
Hi everyone, I am searching for a solution to create a 3D plot to show the whole distribution of load over a cylinder using finite (Nj) numbers of load distribitution in each section of the cylinder in axial direction:
for j=1:Nj
for i=1:Ni
X1(j,i)=2e2*1*cos(theta(1,i));
Y1(j,i)=2e2*1*sin(theta(1,i));
X(j,i)=2e2*LOAD(j,i)*cos(theta(1,i));
Y(j,i)=2e2*LOAD(j,i)*sin(theta(1,i));
end
end
Here the X1 and Y1 describe the normal circle of each cylinder section and X,Y describe the load distibution in each section over this cylinder. What I want is a 3D plot which put all of these sections behind each other and build up the whole cylinder. Can anybody help me?
Thanks all!

답변 (1개)

emehmetcik
emehmetcik 2015년 9월 18일
You can use plot3() function.
figure; hold on;
for j=1:Nj
plot3(X(j, :), Y(j, :), j*ones(size(X(j, :))))
end
view(3);
Also, avoid using nested "for" loops, especially when you can easily use vectorised forms. (e.g. remove the second loop by replacing i with 1:Ni, and replace the matrix products * with elementwise products .*). You can further improve your code with repmat function.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by