Access Field from Struct

128 visualizaciones (últimos 30 días)
N/A
N/A el 25 de Sept. de 2020
Editada: Stephen23 el 25 de Sept. de 2020
Hello everyone,
I need your help with accessing a field from a struct. I am not really familiar with how to use structs.
I got this struct (not mine, therefore I don't really know how to properly work with it) and just want to plot the values that are in the first column.
There is probably a really easy way how to do it. I tried to access the data with something like a=structname.MeansArea, but this gives me only the very first entry of the column. I apprechiate all help.
  1 comentario
Stephen23
Stephen23 el 25 de Sept. de 2020
Editada: Stephen23 el 25 de Sept. de 2020
Structure arrays have two independent features which need to be considered when accessing their data:
  • the size, which determines what indexing you can use.
  • the fields, which determines what field names you can use.
For non-scalar structures you will likely find comma-separated lists to be very useful:
It is also possible to access the fieldnames dynamically:

Iniciar sesión para comentar.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 25 de Sept. de 2020
Editada: Ameer Hamza el 25 de Sept. de 2020
You need to use concatenation brackets [ ]
a=[structname.MeansArea]
  2 comentarios
N/A
N/A el 25 de Sept. de 2020
Thanks for the fast and correct answer.
Ameer Hamza
Ameer Hamza el 25 de Sept. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by