Use cell instead of struct, while keeping data's organization
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2022-7-19
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!