我想把一个给定的序列转换成符合以下规则的2位二进制序列:A = 00,C = 01,T = 10,G = 11。我写了以下代码。
str = 'ATTCGA';
[~,idx]= ismember(upper(str),'ATCG');
C= {'00', '10', '01', '11'};
z= [c{idx}]-'0';
R = 0.992;
theta = (2*pi)/3;
b = [1 0 -1];
a = [1 -2*R*cos(theta) R^2];
u = filter(b,a,z);
Y = abs(u).^2;
plot(Y/max(Y));
axis([0 8000 0 1.05]);但问题是,代码是每个单元生成一个位,而我需要每个单元2个位:

发布于 2017-11-23 20:42:54
你做得很好,你只是在以错误的方式进行索引/连接:
str = 'ATTCGA';
[~,idx] = ismember(upper(str),'ATCG');
dna_map = {'00', '10', '01', '11'};
% Index with parentheses instead of braces, and don't concatenate
dna_bin = dna_map(idx)这将为您提供相应的cell-array:
dna_bin =
'00' '10' '10' '01' '11' '00'但是,不确定您想要如何处理剩下的步骤...
https://stackoverflow.com/questions/47454502
复制相似问题