MATLAB: How to add a column to a cell array based on existing values in another column

if statementloop

Hi,
Only a beginner so forgive me for the basic question… but I have a cell array (x) of dimensions 1310×2. Column 1 is a unique identifier; there are two possible values of the second column, either "A" or "B". I want to add a third column which I want to be "1" if Column 2 is "A" and "0" otherwise.
What is the most efficient way to carry this out?
Should I be using an 'if' statement with a loop?
If so, should I be adding a third (blank) column before carrying out the if statement and populating this with 1's or 0's?
Thanks!

Best Answer

One option is:
x(:,3) = deal({0});
x(ismember(x(:,2),'A'),3) = deal({1});