Borrar filtros
Borrar filtros

How to access column of double in struct array?

19 visualizaciones (últimos 30 días)
Cícero Vicente
Cícero Vicente el 10 de Jun. de 2023
Movida: VBBV el 13 de Jun. de 2023
Hi good people!
I have a shp file (coastlines.shp) and need to get the lat, long and date data that are in the x, y and date (multiple data points) columns in double format and turn them into matrix data. Every time I try to access, I can only get the data from the first line or specific line, I've tried several ways, but without success.
Could be help me?
  3 comentarios
Stephen23
Stephen23 el 10 de Jun. de 2023
Editada: Stephen23 el 10 de Jun. de 2023
The MATLAB approach would be to use comma-separated lists:
But note that all of the X and Y vectors have different lengths: so far your indexing shows that you have not taken this into account. Before you start trying to join them all together, you need to decide how you want to concatenate vectors of different sizes together.
"How to access column of double in struct array?"
None of X and Y are columns vectors, so it seems there might be some confusion about sizes.
Cícero Vicente
Cícero Vicente el 10 de Jun. de 2023
Hi Stephen23
Exactly. That's another question: X, Y and date have different sizes in their vectors, I believe that's why I can't access them. I need a code or solution that accesses the vectors, with their different sizes, and turns them into arrays of columns or something similar. I tried with the 'getfiled' function and other ways, but without success.
Can you help me?

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 10 de Jun. de 2023
"...and turn them into matrix data"
"Can you help me?"
Download this:
and then use it like this:
X = padcat(coast.X)
Y = padcat(coast.Y)
For the dates use a cell array:
D = {coast.date}
  1 comentario
Cícero Vicente
Cícero Vicente el 12 de Jun. de 2023
Stephen23,
Thank u for your help!
I managed to do what I wanted: "how to access column of double in struct array". Now I will work with the data. Thanks.

Iniciar sesión para comentar.

Más respuestas (1)

VBBV
VBBV el 10 de Jun. de 2023
Editada: VBBV el 10 de Jun. de 2023
x(i,:) = 
y(i,:) =
Date(i,:) = 
% rename date in output vector to Date as its already used in the struct

Use the above format as shown which uses the for loop index.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by