converting XYZ file to GRID

11 次查看(过去 30 天)
Javier Abanades
Javier Abanades 2013-6-14
评论: Mike Stin 2020-4-21
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

回答(3 个)

Walter Roberson
Walter Roberson 2013-6-14
  2 个评论
Walter Roberson
Walter Roberson 2013-6-16
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
Javier Abanades 2013-6-17
My problem is that the unique function generates a regular grid and I just want to generate a grid in the points where I have data, beacuse if it generates a regular grid I do not have Z values for every point...
How can I solve it?
  3 个评论
Javier Abanades
Javier Abanades 2013-6-17
I know it is a bit strange but I have an xyz file with thousands of points... so I would like to transform that matrix (2e6,3) into 3 matrix where I can save the values of X, Y and Z respectively.
Instead of one matrix of (2e6,3) having 3 matrix of (1e3, 2e3) where I save X, Y and Z values
Walter Roberson
Walter Roberson 2013-6-18
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
Chad Greene 2016-4-26
I wrote a function for this called xyz2grid.
  1 个评论
Mike Stin
Mike Stin 2020-4-21
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by