필터 지우기
필터 지우기

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
Javier Abanades
Javier Abanades 2013년 6월 14일
I do not follow you
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