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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by