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

1 次查看(过去 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!

回答(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