converting XYZ file to GRID
11 views (last 30 days)
Show older comments
Hello all,
I am trying to convert a XYZ file, i.e.
X Y Z 1.5e3 2.8e6 2 2.5e3 3.8e6 2.1 . . .
into a grid, that would be several matrix for the X, Y and Z values
If I do it with my first file, it works, but if I try with the second one, it does not work properly the function unique creates more values than actually it has for the X and Y matrix, so when I create my Z matrix, there is no enough values...
load = XYZ ('points.xyz');
c=0;
x=unique(XYZ(:,1));
y=unique(XYZ(:,2));
[X,Y] = meshgrid(x,y);
for j=1:758
for i=1:3153
c=c+1;
Z(j,i)=XYZ(c,3);
end;
end;
Does someone know what is wrong? The files are: With this works: https://dl.dropboxusercontent.com/u/22755010/points%20working.dat
With this does not work: https://dl.dropboxusercontent.com/u/22755010/points%20no%20working.xyz Thanks in advance
Javier
0 Comments
Answers (3)
Walter Roberson
on 14 Jun 2013
2 Comments
Walter Roberson
on 16 Jun 2013
if you are getting more values than you expect then possibly the problem is with values that look the same when displayed but are just slightly different. unique is going to notice the slight difference and treat them as different values.
Javier Abanades
on 17 Jun 2013
3 Comments
Walter Roberson
on 18 Jun 2013
At present, your 2e6 x 3 matrix is indexed at (point number, dimension number), where point number is 1 : number of points and the points are not ordered with respect to each other. Dimension number would be 1 for X, 2 for Y, 3 for Z.
After the transform, you want three 2D matrices, one each for X, Y, Z. But what are the indices for those 2D matrices? (1e3 by 2e3) would have the same number of entries as 1e6 x 1 would have, but what is the 1 : 1e3 intended to represent, and what is the 1 : 2e3 to represent?
Chad Greene
on 26 Apr 2016
1 Comment
Mike Stin
on 21 Apr 2020
Hello, I'm completely new here. I have XYZ data in an excelsheet or a text document and would like to edit this data with your script to create a 3d chart interface in Excel.
For this purpose the data must be available in mesh/grid form
However, I am not familiar with Matlab and could use some help.
See Also
Categories
Find more on Data Type Conversion 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!