Use MATLAB to double a parameter until a certain value -
I want to double a parameter (population size) until it reaches a fixed value, even if the number of loops (Generations). Say I have the following loops:
population_sage = 10; Size of initial population for I = 0: 10,% no% for generations (* call function for model *) Population = size = (population_ size + 2); Gene_frequency = (gene_transfer * population_size) / population_ size; Yvon has suggested, use a while
loop which, unless you complete a certain condition, I can see that your population Size is doubling, and you make while
loop, unless it is not equal, or more than this number.
I have a question, however: your gene_frequency
calls seem to be unusable, you're taking variable, multiplying by population_size
, then Population_size
.... and you will get the same number as you did last time, I am leaving this statement because it does not make any meaningful contribution for your question.
Like:
population_ size = 10; % Size of the initial population target_population = ...;% // You come here to the population you want, while the population_size & lt; Target_population% // New% // (* Call Function for Model *) Population_ Size = (Population_ Size * 2);
Edit - July 30, 2014
You mentioned in your comments that you can run it for 15 generations, but when the size of the population It reaches its limit, it will remain for the rest of the generations. You can combine this with a for
loop and a if
statement. If we go through each generation, see to see what the size of the population is. Unless the population size is less than the target population, we will double the size. After the size of the population has increased in the end, it will not double, but the loop will continue until the rest of the generations.
You can do this:
population_ size = 10; % If you want population here for the size of the initial population target_population = ...;% / population = 1: 15% // (* call function for model), if (population_ size and lieutenant = target_ population) population_ size = (Population_image) * 2); End End
Comments
Post a Comment