How to Convert a Logical Vector to a Character Vector?
Show older comments
What is the shortest way to convert a logical vector to a character vector with two arbitrary names for true and false values?
A = [ 0 1 0 1 1 1 ];
B = [ ‘no’ ‘yes’ ‘no’ ‘yes’ yes’ yes’ ]
Accepted Answer
More Answers (1)
Thorsten
on 17 Aug 2016
strrep(strrep(sprintf('%d ', A), '1', 'yes'), '0', 'no')
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!