Error in following code while converting cell to matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Majid Farzaneh
am 21 Jun. 2018
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.
1 Kommentar
Andrei Bobrov
am 22 Jun. 2018
Bearbeitet: Andrei Bobrov
am 22 Jun. 2018
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,[]));
Siehe auch
Kategorien
Mehr zu Power Converters finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!