cell to matrix with numerical and logical values
1 回表示 (過去 30 日間)
古いコメントを表示
i have a cell array with numerical values and logical values and i want to transform it to a matrix with only numerical values. How can i do that? Thanks
0 件のコメント
回答 (2 件)
Star Strider
2018 年 11 月 7 日
Try this:
C = {1:5, (1:6)>3}; % Create Cell Array
N = cell2mat(C(cellfun(@isnumeric,C))) % Desired Output
Note — The numeric elements of your cell array must have the correct dimensions, or the cell2mat call will throw a error for mismatched dimensions when it tries to concatenate them.
0 件のコメント
Stephen23
2018 年 11 月 7 日
Where each cell contains a scalar numeric or logical:
cell2mat(cellfun(@double,C))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!