필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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

댓글을 달려면 로그인하십시오.

추가 답변 (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 CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by