Error in following code while converting cell to matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Majid Farzaneh
le 21 Juin 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 commentaire
Andrei Bobrov
le 22 Juin 2018
Modifié(e) : Andrei Bobrov
le 22 Juin 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,[]));
Voir également
Catégories
En savoir plus sur Power Converters dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!