Does cell2mat work in Matlab 2019?
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Stephen23
2021 年 3 月 2 日
編集済み: Stephen23
2021 年 3 月 2 日
"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.
回答 (1 件)
ANKUR KUMAR
2021 年 3 月 1 日
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 件のコメント
Steven Lord
2021 年 3 月 1 日
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
2021 年 3 月 1 日
編集済み: ANKUR KUMAR
2021 年 3 月 1 日
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.
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!