Fetch data from multi dimensional struct

3 views (last 30 days)
Nandu Anilkumar
Nandu Anilkumar on 17 May 2021
Answered: Rik on 17 May 2021
Hi,
I am new to mat lab and I am facing trouble with structs.
I want to fetch the data from a multi dimensional sturct tree.frame(1x2913 struct) and the frame has data 2913 x 5
I need to extract the field ms from the tree.frame.
Help on this is much appreciated.

Answers (1)

Rik
Rik on 17 May 2021
Referencing the field will generate a comma separated list, which you can capture into a cell array like you would expect:
%create random data to match your data shape and type
tree=struct;for n=1:10,tree.frame(n).ms=regexprep(tempname,'[a-zA-Z\\/_]','');end
{tree.frame.ms}
ans = 1×10 cell array
{'1481219542693683729065232'} {'5125475404699707387627634'} {'61732133440893223508'} {'9917554044059165961542'} {'017395745389198584826'} {'4459127421780622040'} {'36854942756963958'} {'442454896965075980'} {'8960592657449904510260'} {'850664164864943358'}

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!