I want to make a full string from all the "a" values that i get

8 ビュー (過去 30 日間)
IOANNIS KORACHAIS
IOANNIS KORACHAIS 2020 年 12 月 17 日
回答済み: Steven Lord 2020 年 12 月 17 日
reversedDNA = 'TACATGA'
function complementedDNA = r_dnasepinaka(reversedDNA)
n=length(reversedDNA);
ok = num2cell(reversedDNA);
for i=1:n
a = ok{i};
for j = 1:length(a)
if a(j) == 'A';
a(j) = 'T';
elseif a(j) == 'T';
a(j) = 'A';
elseif a(j) == 'C'
a(j) = 'G';
elseif a(j) == 'G';
a(j) = 'C';
end
end
end

採用された回答

Remy Lassalle-Balier
Remy Lassalle-Balier 2020 年 12 月 17 日
I am not completly sure I understood your question but you could do something like this:
reversedDNA = 'TACATGA'
function complementedDNA = r_dnasepinaka(reversedDNA)
complementedDNA = reversedDNA;
complementedDNA(reversedDNA == 'T') = 'A';
complementedDNA(reversedDNA == 'A') = 'T';
complementedDNA(reversedDNA == 'C') = 'G';
complementedDNA(reversedDNA == 'G') = 'C';
end
and something like this to get all the As:
function [UniqueCharStr , PositionList] = getSingleChar(DNA , Char)
PositionList = find( DNA == Char );
UniqueCharStr = DNA( PositionList );
end
getSingleChar(reversedDNA , 'A')
  2 件のコメント
IOANNIS KORACHAIS
IOANNIS KORACHAIS 2020 年 12 月 17 日
The first answear was exactly what i wanted, thank you very much
Remy Lassalle-Balier
Remy Lassalle-Balier 2020 年 12 月 17 日
You are welcome!

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2020 年 12 月 17 日
reversedDNA = 'TACATGA'
reversedDNA = 'TACATGA'
DNA = replace(reversedDNA, {'T', 'A', 'C', 'G'}, {'A', 'T', 'G', 'C'})
DNA = 'ATGTACT'

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by