フィルターのクリア

how to get character from an array using another logical array?

2 ビュー (過去 30 日間)
Mithushan Kanthasamy
Mithushan Kanthasamy 2020 年 9 月 18 日
how to get character from an array using another logical array?
for example
V = '1b.%291x g'
'yig&aaSgwa'
'tqtbbs!?R!'
logicalVec = [ 1 0 1 0 1 0 1 0 1 1; 0 1 1 0 1 0 0 0 1 1; 1 0 1 0 0 1 1 1 0 1]

採用された回答

Turlough Hughes
Turlough Hughes 2020 年 9 月 18 日
A slight modification on your inputs:
V = ['1b.%291x g'; 'yig&aaSgwa'; 'tqtbbs!?R!'];
logicalVec = logical([ 1 0 1 0 1 0 1 0 1 1; 0 1 1 0 1 0 0 0 1 1; 1 0 1 0 0 1 1 1 0 1]);
You can then use a logical index to find the characters corresponding to true values:
V(logicalVec).'
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 18 日
To extract "across" instead of "down",
Vt = V.';
Vt(logicalVec.')
Mithushan Kanthasamy
Mithushan Kanthasamy 2020 年 9 月 18 日
thank you!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by