How to eliminate string array elements by passing binary array

Hello,
I have an array of strings that I would like to manipulate with a secondary binary array. Something like
if true
myStrings = {'Title1','Title2','Title3'};
seconaryArray = [1,0,1];
a = myStrings * secondaryArray;
end
The output I desire from this example is
a = {'Title1','Title3'}
but the error I am receiving is
Undefined function 'mtimes' for input arguments of type 'cell'.
I hope someone can help me with my syntax problem.
Thank you,
Geoff

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 3 月 31 日

1 投票

myStrings = {'Title1','Title2','Title3'};
seconaryArray = [1,0,1];
myStrings(logical(seconaryArray))

1 件のコメント

Geoffrey
Geoffrey 2014 年 3 月 31 日
Thank you for your expedient response. Your solution works perfectly.
Geoff

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

質問済み:

2014 年 3 月 31 日

コメント済み:

2014 年 3 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by