Use cell instead of struct, while keeping data's organization
2 views (last 30 days)
Show older comments
I have a multi-level structure
Struct1=u(t).a(p).b(q).c(r).dat,
where each field has hundreds of subfields.
Initially I am doing a math operation (fft) on the array that's exposed at the end of the structure, to get
Struct2=fft_x(u)=w.
After that, I would like to re-arrange Struct2 to expose now say the
r_1 ,..., r_n
parameters,
Struct3=w(t).a(p).x(x).dat(r_1:r_n)
I now do another math operation on the exposed array elements
r_1:r_m
, and so on: rearrange the fields to expose, then do a math operation.
- Note that I would like the grab also the inner field also.
- Is there a data structure that would be better than struct? I would like organize my data in terms of something more flexible such as cells. However, I need to keep tabs on the data in the same way as structs do.
- I want to employ different data structure not only because speed concerns --- multiple for loops to reorganize data (3 layers of nesting) is not vectorized and hence really slow. I also would like to use gpu (so structs are no good for that)
1 Comment
dpb
on 19 Jul 2022
I think you'd have to outine the data and objectives in sufficient detail somebody could try to design a better data structure that matches the problem -- I think simply trying to make sense of such a convoluted struct as you have described isn't going to happen for anybody on the outside without your inside knowledge of the problem.
Answers (0)
See Also
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!