How to eliminate string array elements by passing binary array

1 view (last 30 days)
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

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 31 Mar 2014
myStrings = {'Title1','Title2','Title3'};
seconaryArray = [1,0,1];
myStrings(logical(seconaryArray))

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!