3D Plot from finite 2D Plots in each section!
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
emehmetcik
on 18 Sep 2015
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 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!