Since you have mentioned that you are new to parallel programming in MATLAB, I suggest going through the following resources:
Regarding the issue at hand, I suggest using "parfor" from the parallel computing toolbox to execute the above loop using multiple workers. The first example in the "Convert a for-Loop Into a parfor-Loop" section of the below document illustrates how a series loop operation may be parallelized.
In this case, the variables "Y_record_generation" and "record_generation" are being shared across all iterations. You will have to make sure that each iteration is totally independent of all the others.
One way to do this could be to make modifcations to your code as shown below:
Y_record_generation(n) = simulation(population(n,:),P);
record_generation(n) = 2*norm(Y(end,2:4)'-[P.tXo;P.tyo;terrain(P.tXo,P.tyo)])^2+0.2*Y(end,1)^2;
You can then calculate the "Y_record_generation" value corresponding to the minimum "record_generation" value as:
Y_record_generation = Y_record_generation(record_generation == min(record_generation));
For further reference, consider going through the following document:
There are certain caveats to using "parfor" which are mentioned in the "Tips" section of the documentation provided above.