# Plotting 3D points from numerous arrays

6 views (last 30 days)
Konstantinos Belivanis on 7 Nov 2014
Answered: Daniel Iyinomen on 7 Jun 2018
Hello all,
I have 210 arrays each one representing the x,y,z coordinates of a point (70 points). My arrays are named Point_1_x, Point_1_y, Point_1_z, etc.
I want to plot a 3D plot of the 70 points at a specific time (assume 20,1 cell in all arrays.
Is there a way to write a loop for the whole procedure with i ranging from 1 to 70 to create this plot as automatically as possible?
Thank you in advance.
##### 1 CommentShow NoneHide None
Dimitrios on 7 Nov 2014
Make it more clear Kwstas! :D

Sign in to comment.

### Accepted Answer

Konstantinos Belivanis on 7 Nov 2014
Well actually, you appented all the points. What I would like is to show all the points (70 points in one plot) at the same time (t=20) in one plot.
##### 4 CommentsShow 3 older commentsHide 3 older comments
Konstantinos Belivanis on 8 Nov 2014
Thanks a lot!!! The eval(sprintf('Point_%d_x(t,1)',i)) was what I was looking for :)
Solved!

Sign in to comment.

### More Answers (2)

Orion on 7 Nov 2014
I don't have data to work with and see the validity of the result, but I guess you need something like
% create array by concatenating the vectors for each directions.
% assuming all Point_1_x, Point_1_y, Point_1_z, etc. are columns vectors.
AllXdat = [];
AllYdat = [];
AllZdat = [];
for i = 1:70
AllXdat = [AllXdat eval(sprintf('Point_%d_x',i))];
AllYdat = [AllYdat eval(sprintf('Point_%d_y',i))];
AllZdat = [AllZdat eval(sprintf('Point_%d_z',i))];
end
% define the time you want to plot, and get the corresponding spatial values,
% assuming the value fot t = 20 is at the 20th position in the vectors : Point_1_x(20),...
mytime = 20;
XatTime = AllXdat(mytime,:);
YatTime = AllYdat(mytime,:);
ZatTime = AllZdat(mytime,:);
% plot at the desired time
plot3(XatTime,YatTime,ZatTime);
##### 1 CommentShow NoneHide None
Konstantinos Belivanis on 8 Nov 2014
Could I add the name of each point next to each point? (to be able to identify them on the graph)?

Sign in to comment.

Daniel Iyinomen on 7 Jun 2018
How can I use Surf to plot 3D graph from a text file. The text is attached and the auto-generated surface is also attached. My problem is drawing the attached auto-generated plot in MATLAB using the attached text file. Please, any help?
##### 0 CommentsShow -1 older commentsHide -1 older comments

Sign in to comment.

### Categories

Find more on Annotations 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!