Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
converting a cell array into a structured array
조회 수: 2 (최근 30일)
이전 댓글 표시
I've imported some .txt files into matlab using the textscan command, where I now have a variable 'C' which is an 8x4 cell, each column of the cell refers to different locations and each row refers to a different measured variable. So, I have 4 locations and 8 variables measured in each.
How is it possible to convert C into a structure (i.e. 4 structures in this case) so that I have a structure for each location and within the structure I have variables defining each cell.
I also have a variable called 'naming' which is also a 8x4 cell where each cell corresponds to the name of each of the different cells in C.
How would I go about achieving this?
I can do it manually by:
new1=struct(name{1,1},C{1,1}{1,1});
But this would be rather time consuming with large datasets.
댓글 수: 0
답변 (2개)
Andrei Bobrov
2012년 2월 21일
try
C1 = C{1};
cn = permute(cat(3,name,C1),[3 2 1]);
new1 = struct(cn{:});
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!