MATLAB: Decoding DNA sequence into binary

binarydna sequencingMATLAB

I have a sequence TGACTCAGTCGTTCAATCTATGCC, how to write code in matlab to convert it into binary? Please help me..Thank you

Best Answer

One way:
s = 'TGACTCAGTCGTTCAATCTATGCC'; % Input DNA string
[~,x] = ismember(s,'ATGC'); % Convert the ATGC into indexes
c = {'00','01','10','11'}; % Numeric strings to convert the indexes into
result = cell2mat(c(x)); % Convert the indexes into the numeric strings