Form a matrix from a structure
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Azzi Abdelmalek
2013년 2월 4일
편집: Azzi Abdelmalek
2013년 2월 4일
Try
x(1,1).data=1;
x(1,2).data=[2 1];
x(2,1).data=rand(2);
x(2,2).data=[1;2];
out=struct2cell(x);
out(:)
댓글 수: 4
Azzi Abdelmalek
2013년 2월 4일
편집: Azzi Abdelmalek
2013년 2월 4일
out=struct2cell(x); % x is your struct variable
out(:)
What did you get?
추가 답변 (2개)
Cedric
2013년 2월 4일
If it is a cell array and cells contents have matching sizes:
>> doc cell2mat
댓글 수: 4
Cedric
2013년 2월 4일
편집: Cedric
2013년 2월 4일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!