Form a matrix from a structure
Mostrar comentarios más antiguos
I have a 32*32 data structure. There are 1*1 structures in each of those 32*32 cells. However, i would like to extract all the binary data in the substructures and align them into one matrix. any one with some code that could help me do this please? Thank you
2 comentarios
Azzi Abdelmalek
el 4 de Feb. de 2013
can you provide an example
Andrew
el 4 de Feb. de 2013
Respuesta aceptada
Más respuestas (2)
Cedric
el 4 de Feb. de 2013
If it is a cell array and cells contents have matching sizes:
>> doc cell2mat
4 comentarios
Andrew
el 4 de Feb. de 2013
Cedric
el 4 de Feb. de 2013
Look at the figure in the doc of cell2mat. Sizes can vary, but they have to match between adjacent blocks. If your aren't in this situations, you'll have to define what how you want to manage gaps (e.g. fill them with NaNs so sizes match..?).
Seems that you edited the question since I posted my answer. Seeing your answer to Azzi, you should just look at what are these variables that you are dealing with, e.g.
>> S = load('Compressed.dat') ;
S =
ans: {...}
data: {...}
>> class(S)
ans =
struct
>> class(S.data)
ans =
cell
>> size(S.data)
ans =
32 32
... doing that would help you truly understand the structure of the objects that you are dealing with, which will allow you to index them correctly.
Andrew
el 4 de Feb. de 2013
Andrew
el 4 de Feb. de 2013
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!