cell2mat error in arraycell

3 ビュー (過去 30 日間)
shamal
shamal 2023 年 11 月 18 日
編集済み: Walter Roberson 2023 年 11 月 19 日
Sis=app.StrategyAggreg_UITable2.Data(:,3);
xx=logical(cell2mat(Sis));
Error using cell2mat
All contents of the input cell array must be of the same data type.
Unable to resolve the name 'app.StrategyAggreg_UITable2.Data'.

採用された回答

Matt J
Matt J 2023 年 11 月 19 日
load Check
xx=logical([Sis{:}]')
xx = 44×1 logical array
1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0

その他の回答 (1 件)

Matt J
Matt J 2023 年 11 月 19 日
load Check
xx=cellfun(@logical,Sis)
xx = 44×1 logical array
1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0
  1 件のコメント
Walter Roberson
Walter Roberson 2023 年 11 月 19 日
編集済み: Walter Roberson 2023 年 11 月 19 日
load Check
classes = cellfun(@class, Sis, 'uniform', 0);
unique_classes = unique(classes)
unique_classes = 2×1 cell array
{'double' } {'logical'}
mask = classes == "logical";
unique([Sis{mask}])
ans = 1×2 logical array
0 1
unique([Sis{~mask}])
ans = 1×2
0 1
So Sis contains cells with logical 0 (false) and logical 1 (true), but it also contains cells with numeric 0 and numeric 1.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by