how to set up two different populations in a segregation model code?
1 view (last 30 days)
Show older comments
I have a general code for the segregation model like the following:
%% n = grid_size;
grid_size = 50;
n = grid_size;
n2 = n^2;
grids = zeros(n);
emp = round((percent_empty/100)*n2);
two = round((percent_two/100)*n2);
tot = emp + two;
rand_loc = randperm(n2);
init_emp = rand_loc(1:emp);
init_two = rand_loc(emp+1:tot);
init_one = rand_loc(tot+1:end);
grids(init_emp) = 3;
grids(init_two) = 2;
grids(init_one) = 1;
figure, imagesc(grids), colorbar, axis([1 n 1 n]);
% frame = getframe;
% writeVideo(writerObj,frame);
how could I insert two populations in this code, that is population 1 are unsatis ed with their location if the number of their neighbours that are from population 2 is u1 or higher, and population 2 occupants are unsatis ed with their location if the number of their neighbours that are from population 1 is u2 or higher. Beside this, p1+p2 is less than 100; the rest can be empty.
0 Comments
Answers (0)
See Also
Categories
Find more on Visual Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!