MATLAB: Convert vector of doubles to a cell of strings

arraycellclassconvertdoublestringvector

Hi,
I have the vector A=[0;1;0;1];
I want to convert this into the cell array A
4 x 1 cell array
{'no'}
{'yes'}
{'no'}
{'yes'}
How is this done?

Best Answer

A=[0;1;0;1]
options = {'no';'yes'};
s = options(A+1)
or perhaps you'd benefit from working with logical arrays,
TF = logical(A);