How to access elements of nested structures

3 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2022-12-29
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'}

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by