Plz help how can i do this

조회 수: 3 (최근 30일)
eman baky
eman baky 2021년 9월 17일
댓글: eman baky 2021년 9월 17일
I have this code
TTmap = {'T' '0' '0' 'T'};
dna_stego={'ATA' 'ACC' 'AAC' 'AAC' 'CAG' 'ACC'};
amino_acid={'CG' 'GG' 'TC' 'CC' 'AC' 'GC' 'CT' 'GT'};
TTmap(end+1:numel(dna_stego)) = {'0'};
ttnonzero = ~strcmp(TTmap,'0').';
dna_stego_out = dna_stego;
count=1;
for k = 1:numel(dna_stego)
aamatches = ismember(dna_stego{count}(1:2),amino_acid);
if (ttnonzero(k)~=0)
if (aamatches==1)
dna_stego_out{count}(3) = TTmap{k};
else
while(aamatches~=1)
count=count+1;
aamatches = ismember(dna_stego{count}(1:2),amino_acid);
end
dna_stego_out{count}(3) = TTmap{k};
end
else
count=count+1;
end
end
and I get the error
Index exceeds matrix dimensions.
Error in test2 (line 12)
aamatches = ismember(dna_stego{count}(1:2),amino_acid)
I want that the output should be
dna_stego_out={'ATA' 'ACT' 'AAC' 'AAC' 'CAG' 'ACT'};

답변 (2개)

William Rose
William Rose 2021년 9월 17일
Your quesiton is not eassy to read bcause you have formatted parts of your question as code that should not be. I think you meant to write:
____________________
the output is
dna_stego_out =
'ATA' 'ATA' 'ATC' 'AAC' 'CAG' 'ACC'
I want it to be
dna_stego_out =
'ATA' 'ATA' 'ATT' 'AAC' 'CAG' 'ACT'
____________________
Please explain what you are trying to do, and explain the logic basis for the output which you want.
  댓글 수: 2
Image Analyst
Image Analyst 2021년 9월 17일
I think I fixed the formatting.
eman baky
eman baky 2021년 9월 17일
I have three vectors
TTmap = {'0' 'T' '0' 'T'};
dna_stego={'ATA' 'ACC' 'AAC' 'AAC' 'CAG' 'ACC'};
amino_acid={'CG' 'GG' 'TC' 'CC' 'AC' 'GC' 'CT' 'GT'};
I wanna replace the value in TTmap with dna_stego_out{n}(3) but under two condition
The first one I replace if TTmap is not equal to zero and if equal zero I do not anything in dna_stego
second one dna_stego{count}(1:2) one of amino_acid if not I will chack another one in dna_stego
in this case, the output suppose be
dna_stego_output
{ 'ATA' 'ACT' 'AAC' 'AAC' 'CAG' 'ACT'}

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


Image Analyst
Image Analyst 2021년 9월 17일
Try this:
TTmap = {'T' '0' '0' 'T'};
dna_stego={'ATA' 'ACC' 'AAC' 'AAC' 'CAG' 'ACC'};
amino_acid={'CG' 'GG' 'TC' 'CC' 'AC' 'GC' 'CT' 'GT'};
TTmap(end+1:numel(dna_stego)) = {'0'};
ttnonzero = ~strcmp(TTmap,'0').';
dna_stego_out = dna_stego;
count=1;
for k = 1:numel(dna_stego)
% Get first two characters of the k'th cell contents.
thisString = dna_stego{count}(1:2);
fprintf('Checking if %s is in the "amino_acid" cell array.\n', thisString);
% See if this character pair matched any pairs in amino_acid.
[ia, index] = ismember({thisString}, amino_acid);
if ia
fprintf(' Found %s at index %d, which is "%s".', thisString, index, amino_acid{index});
else
fprintf(' Did not find %s in amino_acid.\n', thisString);
end
% Uncommented stuff below I didn't bother to figure out.
% if (ttnonzero(k)~=0)
% if (aamatches==1)
% dna_stego_out{count}(3) = TTmap{k};
% else
% while(aamatches~=1)
% count=count+1;
% aamatches = ismember(dna_stego{count}(1:2),amino_acid);
%
% end
% dna_stego_out{count}(3) = TTmap{k};
% end
% else
% count=count+1;
% end
end

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by