Convert nested cell array into single cell array

8 vues (au cours des 30 derniers jours)
Mausmi Verma
Mausmi Verma le 22 Déc 2021
Commenté : Mausmi Verma le 26 Déc 2021
I am getting variable value in workspace in the form of nested cell array
A={{[1] [2] [3]} {[4] [5] [6]}}
but i want answer in the form of single cell array as,
B={[1 2 3] [4 5 6]}
please help

Réponse acceptée

Voss
Voss le 22 Déc 2021
Modifié(e) : Voss le 22 Déc 2021
A = {{[1] [2] [3]} {[4] [5] [6]}};
B = cellfun(@(x)[x{:}],A,'UniformOutput',false);
display(A);
A = 1×2 cell array
{1×3 cell} {1×3 cell}
display(B);
B = 1×2 cell array
{[1 2 3]} {[4 5 6]}
  1 commentaire
Mausmi Verma
Mausmi Verma le 26 Déc 2021
Exactly what i needed , thanks a lot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by