逻辑字符使用问题?

2 vues (au cours des 30 derniers jours)
腾龙游戏网址l7787482287
N=zeros(1,3);
for i=1:243
if a(3*i)=='C'
N(1)=N(1)+1;
elseif a(3*i)=='G'
N(2)=N(2)+1;
elseif a(3*i)=='C'| a(3*i)=='G' %这个地方运行不出结果,改为 elseif a(3*i)=='C'| 'G'后出结果,但是应该不对
N(3)=N(3)+1;
end
end
a是729个由A、C、G、T组成的字符串,目的是计算第3、6、9、12(三的倍数)出现C、G、C或G的数目。
敬请大神指点

Réponse acceptée

大子 胆
大子 胆 le 10 Juil 2022
a(3*i)=='C'| a(3*i)=='G'
修改为
isequal( a(3*i), 'C' ) || isequal( a(3*i), 'G' )
试试

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!