3D Plot from finite 2D Plots in each section!
조회 수: 2 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!