# How to combine cell arrays with different dimensions?

17 vues (au cours des 30 derniers jours)
Bhakti Khera le 28 Sep 2022
Commenté : Bhakti Khera le 28 Sep 2022
Hello guys!
I have a cell array of a size 2*117 like this:
I want to combine two rows such that resulting cell array is 1*117, i.e.there is only single row.
for example, from above image, output should be something like this:
1*117 cell
1 2 3 4 5
400*1 double 480*1 double 460*1double 560*1 double 400*1double ...............so on................
Thank you!!!
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

the cyclist le 28 Sep 2022
Here is one way:
% Simplified version of your data
C = {rand(2,1), rand(3,1);
rand(5,1), rand(7,1)};
% Concatenate the two rows
cellfun(@(x,y)[x;y],C(1,:),C(2,:),'UniformOutput',false)
ans = 1×2 cell array
{7×1 double} {10×1 double}
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Bhakti Khera le 28 Sep 2022
Thanks! It works perfectly!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Creating and Concatenating Matrices 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!

Translated by