How to access elements of nested structures

3 Ansichten (letzte 30 Tage)
Behrooz Daneshian
Behrooz Daneshian am 29 Dez. 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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 29 Dez. 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'}

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by