Convert Cell to Matrix

8 vues (au cours des 30 derniers jours)
ha ha
ha ha le 26 Juin 2019
Let' say, I have cell_A: 5x1 cell
cell_A={ [] ; [1] ; [5]; [] ; [2]};
How can I convert it to be matrix? 5-by-1 matrix
result_matrix=[ []; 1; 5 ; [] ; 2 ];

Réponse acceptée

madhan ravi
madhan ravi le 26 Juin 2019
As sir Walter mentioned already , you cannot have holes in matrices . So you could replace them with nans perhaps:
cell_A(cellfun('isempty',cell_A)) = {NaN};
Matrix = cell2mat(cell_A)

Plus de réponses (1)

Walter Roberson
Walter Roberson le 26 Juin 2019
You cannot. Matrices cannot have "holes" in them.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by