Does cell2mat work in Matlab 2019?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I try to covert a matrix with numbers (in a cell) to a double matrix. This is the erro I get.
The issue seems to be the curly brakets used in line 36 of cell2mat? I tried to change it and it turns out it is 'read only'.
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) ||
isstruct(c{1})
1 comentario
Stephen23
el 2 de Mzo. de 2021
Editada: Stephen23
el 2 de Mzo. de 2021
"The issue seems to be the curly brakets used in line 36 of cell2mat? I tried to change it and it turns out it is 'read only'."
Do NOT change any files in the installation folder of any application (i.e. under Program Files, etc). If you change these files you are likely to introduce bugs and incompatibilities which are then almost impossible to locate or repair.
The issue is actually that you are calling cell2mat on a numeric array.
Respuestas (1)
ANKUR KUMAR
el 1 de Mzo. de 2021
It is working well for me.
C = {[1], [2 3 4];
[5; 9], [6 7 8; 10 11 12]}
A = cell2mat(C)
1 2 3 4
5 6 7 8
9 10 11 12
Make sure you have the contents of cells in the same column must have the same number of columns, although they need not have the same number of rows. See this for your reference.
4 comentarios
Steven Lord
el 1 de Mzo. de 2021
A isn't a cell array. If you want to convert the other way, turn a matrix into a cell array, use mat2cell.
ANKUR KUMAR
el 1 de Mzo. de 2021
Editada: ANKUR KUMAR
el 1 de Mzo. de 2021
If you wish to convert cell to mat, input should be in a cell format.
A={[ 3 -3 -3 4; 4 -2 3 4; -6 -3 -3 -2; 5 5 5 4]}
cell2mat(A)
There is no point to save single matrix in cell, and then use cell2mat to again get back to matrix from cell, unless you wish to play with matlab.
Indexing is supporting in cell2mat, but for that, input data should have an index. A regular matrix does not have an index of its own. It has the indices of its elements.
Hope it clears.
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!