I eventually need to make 1,000,000 unique sequences using these 2 letters (representing amino acids). Right now, I am only making 100 so my code can run faster. I can make all of these sequences and display them in the loop, but what I want to do is take these sequences and put them in a matrix so that I can use the unique function to compare all the rows in the matrix and ensure that these sequences are in fact unique and that there are no repeats. How can I take the random sequences I create and put them in a matrix fromt he loop?
N = 50; %length of sequence
Num_Sequences = 100; %number of sequences to analyze later
q = 1; %counter for for loop
Num_N = 40; %number of Asparagines in the sequence
Num_V = 10; %number of Valines in the sequence
pf = zeros(1,N); %pf displays the location that valines were placed in sequence
aacids = []; %aacids is the string that contains the sequence
A = []; while q <= Num_Sequences aacids = 'NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN'; for i = 1:Num_V m = randi(N); while ismember(m,pf) %this while loop is to check if the location of aacids has already
m = randi(N); %been selected and then picks another random number
end aacids(m) = "V"; pf(i) = m; end q = q+1;end disp(aacids); %unique(aacids)
>> Random_Sequences
NNNVNNNNNNNVNNNNNVNNNVNVVVVNNNNNVNNNNNNNNVNNNNNNNN
Best Answer