How to turn a Yes/No cell array into binary (0-1)
2 ビュー (過去 30 日間)
古いコメントを表示
I have a Yes/No cell array of 4000x1 and want to turn it into a binary system
Thanks for your attention
0 件のコメント
回答 (2 件)
Jon
2022 年 7 月 5 日
A = {true,false;false,true}
B = cell2mat(A)
5 件のコメント
Jon
2022 年 7 月 5 日
When you say that your matrix contains NA, does that stand for Not Applicable. Since the result is binary true or false you can't have a binary array that has three kinds of values, so you have to pick either true or false for the NA's. The above code will work however it will consider NA to be false. If you want them to be true, you could do something like
B = strcmpi(A,'yes')|strcmpi(A,'NA')
Jon
2022 年 7 月 6 日
Did this solve your problem? If so please accept the answer so others will know that a solution is available
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!