plz help how can use go to in MATLAB

조회 수: 2 (최근 30일)
eman baky
eman baky 2021년 7월 30일
편집: eman baky 2021년 8월 24일
i wrote this code
Truth_Taple_mapping = {'T' '0' '0' 'G' '0' '0' 'G'}
dna_stego={'ATG' 'TCG' 'ATC' 'TTC' 'ACC' 'CCC' 'ACC' 'AAC' 'CAG' 'ACC'}
count=1;
for m=1:numel(Truth_Taple_mapping)
if (Truth_Taple_mapping{m}~=0)
num=get_codon(dna_stego{count}); % n1
if(num==1)
temp=dna_stego{count};
temp(3)=Truth_Taple_mapping{m};
dna_stego{count}=temp ;
else
count=count+1;
% goto n1
end
end
where
Truth_Taple_mapping = {'T' '0' '0' 'G' '0' '0' 'G'},dna_stego={'ATG' 'TCG' 'ATC' 'TTC' 'ACC' 'CCC' 'ACC' 'AAC' 'CAG' 'ACC'}
TCG,TCC,ACC,CCC that can be change
i try to replace the third char in each cell in dna_stego with Truth_Taple_mapping if not equal zero and dna_stego can be changed
TCG,TCC,ACC,CCC and i used get_codon function to determiate that return 1 if it can be change and 0 if not
the output must be { 'ATG' 'TCT' 'ATC' 'TTC' 'ACG' 'CCC' 'ACC' 'AAC' 'CAG' 'ACG'}
and try but i cant do it
  댓글 수: 4
DGM
DGM 2021년 7월 30일
편집: DGM 2021년 7월 30일
Well, this is one step simpler, but I'm not really sure how the results are supposed to come about from this process.
Truth_Taple_mapping = {'T' '0' '0' '0' 'G' '0' '0' 'G' '0'}; % only T or G
dna_stego={'ATG' 'TCG' 'ATC' 'TTC' 'ACC' 'CCC' 'ACC' 'AAC' 'CAG' 'ATC'}
amino_acid={'CG' 'GG' 'TC' 'CC' 'AC' 'GC' 'CT' 'GT'};
for m=1:numel(Truth_Taple_mapping)
if ~strcmp(Truth_Taple_mapping{m},'0')
for k=1:numel(dna_stego)
if ismember(dna_stego{k}(1:2),amino_acid) % this is the same as get_codon
dna_stego{k}(3) = Truth_Taple_mapping{m}; % simplified assignment
end
end
end
dna_stego % intermediate results are overwritten
end
To clarify, these operations can only change the last character in the sequence, and the last character can only be changed to either T or G.
You want some sequences to have the last character changed to T, and some to be changed to G, but the tests are applied identically and depend only on the first two characters. The consequence is that the sequences that are changeable will have the third character changed to G, since it's last in the list.
The last sequence is ATC, which is supposed to be changed to ACG, but neither is AT a prefix in the list, nor is the second character supposed to change. The only description of intent is your code, and it does not describe any behavior consistent with the expected output. I don't know whether your inputs are wrong or whether the expected outputs are.
I am completely unfamiliar with the conceptual signficance of what's being done here, so I'm not sure what to recommend.
Rik
Rik 2021년 7월 30일
@eman baky Please don't flag other questions if you're just asking for help. Flags are to attract the attention of site admins.

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

답변 (2개)

Walter Roberson
Walter Roberson 2021년 7월 30일
MATLAB itself does not have a GO TO, and never will.
Simulink diagrams sort of have a GO TO but it does not affect flow of control and is instead just a way to be able to name a signal and bring the signal to an arbitrary point by name.
I believe that Simscape diagrams can have GO TO.
However, I do not see anywhere in the code where a GO TO would be used even if GO TO existed??
  댓글 수: 5
Walter Roberson
Walter Roberson 2021년 8월 23일
편집: Walter Roberson 2021년 8월 23일
Change
num=get_codon(dna_stego{count}); % n1
if(num==1)
temp=dna_stego{count};
temp(3)=Truth_Taple_mapping{m};
dna_stego{count}=temp ;
else
count=count+1;
% goto n1
end
to
num = get_codon(dna_stego{count}); % n1
while num ~= 1
count=count+1;
end
temp = dna_stego{count};
temp(3) = Truth_Taple_mapping{m};
dna_stego{count} = temp ;
You will notice that this is an infinite loop (until you reach array out of bounds error) in the case that the result of the get_codon is not 1 -- as is required to emulate what would happen if you could "goto" after the %n1 comment.
eman baky
eman baky 2021년 8월 24일
Thank you, sir

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


DGM
DGM 2021년 7월 30일
I'm going to guess that the nonzero content of the "truth taple mapping" vector is supposed to correspond to the locations where the prefix of dna_stego matches amino_acid, in other words elements 2,5, and 10. If that's the case, it's not the right length, and the elements aren't even in the right locations.
The last sequence in dna_stego can't be changed, given the existing description of intended behavior. Either it's wrong or amino_acid is missing AT. I am going to choose to change it to ACC.
% this is probably unnecessarily fragile due to the required index
% correspondence, but i don't know the meaning of these operations
TTmap = {'0' 'T' '0' '0' 'G' '0' '0' '0' '0' 'G'};
dna_stego={'ATG' 'TCG' 'ATC' 'TTC' 'ACC' 'CCC' 'ACC' 'AAC' 'CAG' 'ACC'};
amino_acid={'CG' 'GG' 'TC' 'CC' 'AC' 'GC' 'CT' 'GT'};
% this works so long as all sequences are the same length
dna_stego_out = vertcat(dna_stego{:});
ttnonzero = ~strcmp(TTmap,'0').';
aamatches = ismember(dna_stego_out(:,1:2),amino_acid);
dna_stego_out(ttnonzero & aamatches,3) = [TTmap{ttnonzero}];
dna_stego_out = num2cell(dna_stego_out,2).'
dna_stego_out = 1×10 cell array
{'ATG'} {'TCT'} {'ATC'} {'TTC'} {'ACG'} {'CCC'} {'ACC'} {'AAC'} {'CAG'} {'ACG'}
My suspicion is that TTmap is something that's supposed to be calculated in-process, otherwise its very existence implies that you already know exactly which sequences in TTmap are going to be changed. If that's already been determined, why are we doing it again?
  댓글 수: 5
DGM
DGM 2021년 8월 24일
If they aren't the same length, then what is the relationship between them? Is it shorter by 1? by 3? Is it variable?
This whole time I've been guessing what the code was supposed to do, and I'm still chasing an ill-defined problem with no clarification. If there's not a 1:1 correspondence between TTmap and dna_stego, then you're going to have to define what there is, otherwise there's no way to know what corresponds to what.
eman baky
eman baky 2021년 8월 24일
편집: eman baky 2021년 8월 24일
There is no relationship between them. This is part of the code hiding data in DNA TTmap is sequence includes data and I wanna put them in dna_stego but under condition
if 0 I will change not
if not equal 0 I will check dna_stego if will change or not if allowed I will change the third char with TTmap
for checking dna_stego I used function return 0 if not and 1 if allowed
but here I wrote what can change by compare dna_stego with amino_acid if dna_stego second and third character is a member in amino_acid it allowed
amino_acid={'CG' 'GG' 'TC' 'CC' 'AC' 'GC' 'CT' 'GT'};

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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by