Effacer les filtres
Effacer les filtres

converting XYZ file to GRID

11 vues (au cours des 30 derniers jours)
Javier Abanades
Javier Abanades le 14 Juin 2013
Commenté : Mike Stin le 21 Avr 2020
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

Réponses (3)

Walter Roberson
Walter Roberson le 14 Juin 2013
  2 commentaires
Javier Abanades
Javier Abanades le 14 Juin 2013
I do not follow you
Walter Roberson
Walter Roberson le 16 Juin 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.

Connectez-vous pour commenter.


Javier Abanades
Javier Abanades le 17 Juin 2013
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 commentaires
Javier Abanades
Javier Abanades le 17 Juin 2013
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 le 18 Juin 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?

Connectez-vous pour commenter.


Chad Greene
Chad Greene le 26 Avr 2016
I wrote a function for this called xyz2grid.
  1 commentaire
Mike Stin
Mike Stin le 21 Avr 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by