Plz help how can i do this
조회 수: 3 (최근 30일)
이전 댓글 표시
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'};
댓글 수: 0
답변 (2개)
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
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!