how can I fix the code for Segregation Model and population?

1 view (last 30 days)
I have a code like this:
% model
function schell(grid_size,percent_empty,percent_p1,percent_p2)
grid_size = 50; percent_empty = 30; percent_p1 = 30; percent_p2 = 50;
n = grid_size;
n2 = n^2;
grids = zeros(n); % a grid that occupied by a being from population 1 or 2.
emp = round((percent_empty/100)*n2);
p1 = round((percent_p1/100)*n2);
p2 = round((percent_p2/100)*n2);
tot = emp + p1 + p2;
rand_loc = randperm(n2);
init_emp = rand_loc(1:emp);
init_p1 = rand_loc(emp+1:tot);
init_p2 = rand_loc(tot+1:end);
figure, imagesc(grids);
% frame = getframe;
% writeVideo(writerObj,frame);
but it says "Error using model
Error: File: model.m Line: 1 Column: 10
Class name and filename must match."
How can I fix this? I named this file as "matlab_project".
In this code, I want to include an m * n grid where the "squares" are either unoccupied, or occupied by a being from populations 1 or 2. Initially p1% of the squares are occupied by population 1 occupants, and p2% by population 2, where p1 + p2 < 100. This also have to relate to Segregation Model and population.

Answers (0)


Find more on Financial Toolbox 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!

Translated by