schelling - incrased. B=sw1(A); % The next iteration

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function A=schelling(M,N) A=round(rand(M,N)); % Random zero-one matrix of size MxN colormap([0 0 1; 1 0 0 ]); imagesc(A);axis('equal');axis off;pause(1) test=1; k=1; while (test==1 & k<30); % Bail out after 30 iterations, or when A=B. This typically indicates % "cycling". This value can be
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: incrased. B=sw1(A); % The next iteration imagesc(B);axis('equal');axis off;pause(1/5) % You may replace pause(1/5) pause for step-by-step control Atest=A-B; % Are A and B the same? test=any(Atest(:)); % is test=0 ? A=B; % If test=1, then reassign A k=k+1; end...
View Full Document

Ask a homework question - tutors are online