Vector from character array
1 回表示 (過去 30 日間)
古いコメントを表示
If I have a character array for example:
A={'high','low','low'}
I want to introduce a vector for example B in which if the it says 'high' in A I would have 1 and 0 for the ones that are 'low', something like:
B=[1,0,0]
How can I do that? Thanks in advance.
0 件のコメント
採用された回答
DGM
2021 年 8 月 2 日
編集済み: DGM
2021 年 8 月 2 日
Something like this
A = {'high','low','low'};
B = strcmp(A,'high')
Bear in mind that this only tests whether elements of A contain 'high'. It's implied that the only possible contents are 'high' and 'low', so that should be sufficient. If it's not, then we need to ask how other inputs should be represented.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!