Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Using the Find Function

조회 수: 1 (최근 30일)
Bianca Batista
Bianca Batista 2018년 5월 14일
마감: Stephen23 2018년 5월 14일
Hi! I have written the following script:
number_trials=10000;
number_generations=21;
number_resistant_colonies_Darwin=zeros(number_trials,1);
final_number_bacteria=150*2^21;
alpha=1e-8;
for j=1:number_trials
NWild=zeros(1,number_generations+1);
NMutant=zeros(1,number_generations+1);
NWild(1)=150;
NMutant(1)=0;
for i=1:number_generations
New_born_mutants=poissrnd(alpha*NWild(i));
NWild(i+1)=(2*NWild(i))-New_born_mutants;
NMutant(i+1)=(2* NMutant(i))+New_born_mutants;
end
number_resistant_colonies_Darwin(j)=NMutant(end);
end
generation_number=zeros(number_trials,1)
I would like to be able to record in which generation number the first mutant appeared and keep that generation number (for each trial) tabulated in the generation_number vector. I was looking into the find function but am uncertain about how to input it and also where in the nested for loop it would go. If there is an easier way than the find function, I would be happy to learn about that too! Thank you very much.
  댓글 수: 1
Stephen23
Stephen23 2018년 5월 14일
Follow-up / Duplicate which indicates the question has been resolved:

답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by