How i can convert cell (each element in cell with different length) to array?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ameer Kadhim
le 1 Juin 2018
Modifié(e) : Stephen23
le 1 Juin 2018
hello everybody how I can convert this cell to array such that I want each element in cell in row in array
ex = {[1,2,4,5,7,11,12],[1,3,4,5,7,11,12],[1,2,4,6,5,7,11,12],[1,3,4,6,5,7,11,12],[1,2,4,5,8,13,7,11,12],[1,3,4,5,8,13,7,11,12],[1,2,4,6,5,8,13,7,11,12],[1,3,4,6,5,8,13,7,11,12]};
1 commentaire
Réponse acceptée
Anton Semechko
le 1 Juin 2018
Is this kind of what you are looking for?
ex = {[1,2,4,5,7,11,12],[1,3,4,5,7,11,12],[1,2,4,6,5,7,11,12],[1,3,4,6,5,7,11,12],[1,2,4,5,8,13,7,11,12],[1,3,4,5,8,13,7,11,12],[1,2,4,6,5,8,13,7,11,12],[1,3,4,6,5,8,13,7,11,12]};
n=numel(ex);
N=zeros(n,1);
for i=1:n
N(i)=numel(ex{i});
ex{i}=ex{i}(:)';
end
if min(N)<max(N)
dN=max(N)-N;
for i=1:n
if dN(i)>0
ex{i}=cat(2,ex{i},nan(1,dN(i)));
end
end
end
ex=cell2mat(ex(:));
disp(ex)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Operators and Elementary Operations 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!