Borrar filtros
Borrar filtros

Transform matrices to XYZ

6 visualizaciones (últimos 30 días)
Adi Purwandana
Adi Purwandana el 18 de Mzo. de 2023
Comentada: Star Strider el 19 de Mzo. de 2023
Hello,
I have a mat file containing 3 variables connected each other:
lon --> 19200x1 double
lat --> 9600x1 double
depth --> 9600x19200 double
I want to create an XYZ format (column X for lon; column Y for lat; column Z for the depth value for respected lon and lat value). So that each lon-lat has respected depth value. Does anyone know how to do that?
Thank you for your attention!

Respuesta aceptada

Star Strider
Star Strider el 19 de Mzo. de 2023
Something like this should work —
[Lat,Lon] = ndgrid(lat,lon);
LatLonDepth = [Lat(:) Lon(:), depth(:)];
Since I do not know how the ‘depth’ matrix was created, this could also be appropriate:
[Lat,Lon] = meshgrid(lat,lon);
LatLonDepth = [Lat(:) Lon(:), depth(:)];
You will need to determine which is most appropriate. The ndgrid and meshgrid functions create their matrices differently, so one result will be correct and the other will not. You will need to determine that. If you know which one was used to calculate the ‘depth’ matrix, then choose that function. If you do not, it will be necessary to see which one accurately assigns the correct ‘lat’ and ‘lon’ values to the correct ‘depth’ value.
The (:) subscript operator creates column vectors from the corresponding matrices. They should all have the same row sizes.
.
  2 comentarios
Adi Purwandana
Adi Purwandana el 19 de Mzo. de 2023
Really answering my question...Thank you!
Star Strider
Star Strider el 19 de Mzo. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by