Plz help how can i do this
3 views (last 30 days)
Show older comments
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 Comments
Answers (2)
William Rose
on 17 Sep 2021
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 Comments
Image Analyst
on 17 Sep 2021
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 Comments
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!