Why error using cell2mat ?
3 次查看(过去 30 天)
显示 更早的评论
Hi all, I have a 309 * 5956 cell array of same type and same length. however most of the elements are empty.
However using cell2array to convert this matrix to numerical it gives me error as:
cell2mat(all_i_dis)
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 79)
m = cat(1,m{:});
any idea is highly appreciated.
0 个评论
采纳的回答
Azzi Abdelmalek
2013-7-19
A={ 1 , 2 ; [], 4};
cell2mat(A);
The result
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 87)
m = cat(2,m{:});
To use cell2mat, all cells must be the same size and same class
3 个评论
Azzi Abdelmalek
2013-7-19
编辑:Azzi Abdelmalek
2013-7-19
A(cellfun('isempty',A))={0}
%or
A(cellfun('isempty',A))={nan}
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!