Error in following code while converting cell to matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
Error in following code
Error using cell2mat (line 52)
CELL2MAT does not support cell arrays containing cell arrays or objects.
Error in Fusion_Minutie_InvMoment (line 18)
fusion = cell2mat(out);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
V = {load('db1.mat'),load('db2.mat'),load('db3.mat'),load('db4.mat')};
n = cellfun(@fieldnames,V,'un',0);
V1 = cellfun(@(x,y)[x.(y)]',V,[n{:}],'un',0);
V2 = [V1{:}];
V3 = cell2mat(reshape(V2,1200,[]));
V4 = mat2cell(V3,4*ones(size(V3,1)/4,1),7);
out = mat2cell(V4,[400,800],1);
fusion = cell2mat(out);
댓글 수: 0
답변 (2개)
Majid Farzaneh
2018년 6월 21일
Hi, you can do it like this:
V = {load('db1.mat'),load('db2.mat'),load('db3.mat'),load('db4.mat')};
n = cellfun(@fieldnames,V,'un',0);
V1 = cellfun(@(x,y)[x.(y)]',V,[n{:}],'un',0);
V2 = [V1{:}];
V3 = cell2mat(reshape(V2,1200,[]));
V4 = mat2cell(V3,4*ones(size(V3,1)/4,1),7);
out = mat2cell(V4,[400,800],1)
fusion1 = cell2mat(out{1});
fusion2= cell2mat(out{2});
fusion=[fusion1;fusion2];
In your cell matrix (out) there are 2 other cell matrix. For using cell2mat you should have normal matrix in 'out' cell matrix.
Andrei Bobrov
2018년 6월 22일
편집: Andrei Bobrov
2018년 6월 22일
fusion = cell2mat(cat(1,out{:}));
or just
V = {load('db1.mat'),load('db2.mat'),load('db3.mat'),load('db4.mat')};
n = cellfun(@fieldnames,V,'un',0);
V1 = cellfun(@(x,y)[x.(y)],V,[n{:}],'un',0);
fusion = cell2mat(reshape(cat(1,V1{:}),1200,[]));
참고 항목
카테고리
Help Center 및 File Exchange에서 Power Converters에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!