Keeping track of numbers randomly generated

2 次查看(过去 30 天)
This is the beginning of a for loop that determines the time the 'Binding_tRNA' adds in a set of given circumstances.
I'd like to output a table that keeps track of the Binding_tRNA numbers generated and whether they are Cognate, Near_Cognate, or Non_Cognate
for k = 1:maxIterations
Binder = rand;
Low = Binder<=Weight_Range;
Binding_tRNA = Fluitt1{end-(sum(Low)-1),'tRNA_'}
Cognate = sum(Binding_tRNA == Cognate_tRNAs);
Near_Cognate = sum(Binding_tRNA ==Near_Cognate_tRNAs);
Non_Cognate = sum(Binding_tRNA == Non_Cognate_tRNAs);
A = zeros((Cog_Attempts+Near_Cog_Attempts+Non_Cog_Attempts),2)
Sorry, I know it's not pretty I'm very new to coding
  2 个评论
madhan ravi
madhan ravi 2019-6-12
Upload the missing datas also the tables as .mat file.
Sumara
Sumara 2019-6-12
I think this covers it?
Fluitt2_Cognate_Array = table2array(Fluitt2(:,2:5));
Fluitt2_NC_Array = table2array(Fluitt2(:,[2,6:end]));
Fluitt_NC = Fluitt2_NC_Array(:,2:end);
Cog_and_NC = [Fluitt2_Cognate_Array(:,2:end),Fluitt_NC];
Cog_and_NC2 = array2table(Cog_and_NC);
NonC_tRNAs = rowfun(@(varargin) setdiff(1:48, cell2mat(varargin)), Cog_and_NC2, 'OutputFormat', 'cell');
Codon = randi([0,64]);
Cognate_tRNAs = Fluitt2_Cognate_Array(Codon,2:end);
Near_Cognate_tRNAs = Fluitt2_NC_Array(Codon,2:end);
Non_Cognate_tRNAs = NonC_tRNAs{Codon,:};
Weight_Range = Fluitt1{1:end,'WeightRange'};
Num = 1;
maxIterations = 5;
for k = 1:maxIterations
Binder = rand;
Low = Binder<=Weight_Range;
Binding_tRNA = Fluitt1{end-(sum(Low)-1),'tRNA_'};
Cognate = sum(Binding_tRNA == Cognate_tRNAs);
Near_Cognate = sum(Binding_tRNA ==Near_Cognate_tRNAs);
Non_Cognate = sum(Binding_tRNA == Non_Cognate_tRNAs);
end

请先登录,再进行评论。

采纳的回答

Sumara
Sumara 2019-6-12
编辑:Sumara 2019-6-12
Hey all, nevermind, i figured it out, I was being dumb!!!
A=zeros(maxIterations,7);
for k = 1:maxIterations
Binder = rand;
Low = Binder<=Weight_Range;
Binding_tRNA = Fluitt1{end-(sum(Low)-1),'tRNA_'};
Cognate = sum(Binding_tRNA == Cognate_tRNAs);
Near_Cognate = sum(Binding_tRNA ==Near_Cognate_tRNAs);
Non_Cognate = sum(Binding_tRNA == Non_Cognate_tRNAs);
A(k,1:4) = [Binding_tRNA Cognate Near_Cognate Non_Cognate];
(I reference the other 3 variables in A in nested loops below this for loop)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by