Effacer les filtres
Effacer les filtres

How to access elements of nested structures

3 vues (au cours des 30 derniers jours)
Behrooz Daneshian
Behrooz Daneshian le 29 Déc 2022
Hi all,
I have a nested structure. A 1*1 struct(data) contains a 1*1 struct(metadata) and a 245*1 struct(results). I want to access the column 'id' within a 245 *1 struct. Can anyone teach me how to do that? the nested structure is attached here.

Réponse acceptée

Image Analyst
Image Analyst le 29 Déc 2022
Try this:
s = load('data.mat')
s = struct with fields:
data: [1×1 struct]
id = {s.data.results.id}'
id = 245×1 cell array
{'GHCND:USC00310090'} {'GHCND:USC00310184'} {'GHCND:USC00310212'} {'GHCND:USC00310241'} {'GHCND:USC00310286'} {'GHCND:USC00310356'} {'GHCND:USC00310375'} {'GHCND:USC00310506'} {'GHCND:USC00310576'} {'GHCND:USC00310645'} {'GHCND:USC00310674'} {'GHCND:USC00310724'} {'GHCND:USC00310750'} {'GHCND:USC00310843'} {'GHCND:USC00310901'} {'GHCND:USC00310982'} {'GHCND:USC00311055'} {'GHCND:USC00311156'} {'GHCND:USC00311165'} {'GHCND:USC00311221'} {'GHCND:USC00311222'} {'GHCND:USC00311239'} {'GHCND:USC00311248'} {'GHCND:USC00311420'} {'GHCND:USC00311429'} {'GHCND:USC00311515'} {'GHCND:USC00311535'} {'GHCND:USC00311564'} {'GHCND:USC00311578'} {'GHCND:USC00311606'}
  1 commentaire
Behrooz Daneshian
Behrooz Daneshian le 29 Déc 2022
Thank you so much for your help.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Structures 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