Plz help how can i do this

3 views (last 30 days)
eman baky
eman baky on 17 Sep 2021
Commented: eman baky on 17 Sep 2021
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'};

Answers (2)

William Rose
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
Image Analyst on 17 Sep 2021
I think I fixed the formatting.
eman baky
eman baky on 17 Sep 2021
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'}

Sign in to comment.


Image Analyst
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

Community Treasure Hunt

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

Start Hunting!