Question Source Code: ZOMBIES.m clear all close all % TASK 1: Construct A…
Question Source Code: ZOMBIES.m clear all close all % TASK 1: Construct A… Image transcription textObjective Humanity is threatened by a zombie outbreak.There are two types of zombies: fast zombies (like in I AmLegend) and slow zombies (like in The Walki… Show more… Show moreImage transcription text4. (3 pts) Set 7′ = 1″ 0.01 andedit A using this value of 1″. Setlaml to be the dominant e… Show more… Show moreSource Code:ZOMBIES.m clear allclose all% TASK 1: Construct A with r = .5, print A (no semi-colon)A = zeros(3) % CHANGE THIS % TASK 2: Set x0, compute x7 and x30 % Plot of the dominant eigenvalue as r variesr = .5:.01:1; % values of r from .5 to 1for i=1:length(r) A(2,1) = 1-r(i) lam = eig(A); % all eigenvalues e(i) = max(lam); % dominant eigenvalueend figureplot(r,e,’.-‘)xlabel(‘Proportion of People Vaccinated (r)’)ylabel(‘Dominant Eigenvalue’) % TASK 3: Add a comment in the space below%{The zombie apocalypse will be avoided if at least this percentage of people are vaccinated: %} % TASK 4: Set r=r^*-.01, edit A, set lam1 as the dominant eigenvaluer = NaN; % CHANGE THIS lam1 = 0; % CHANGE THIS % Plot the populations over timeif ~isnan(r) D = 200; x = [20; 0; 0]; P = x; for k=1:D x = A*x; % population vector x day k P = [P x]; % store all the population vectors for plotting end figure days=0:D; plot(days,P) xlabel(‘days’); ylabel(‘population’) legend(‘infected people’,’fast zombies’,’slow zombies’,… ‘location’,’best’) title([‘Zombie Apocalypse: r = ‘ num2str(r) ‘, lambda_1 = ‘ num2str(lam1)]) xlim([0 D])end % TASK 5: Set r=r^*+.01, edit A, set lam1 as the dominant eigenvaluer = NaN; % CHANGE THIS lam1 = 0; % CHANGE THIS % Plot the populations over timeif ~isnan(r) D = 200; x = [20; 0; 0]; P = x; for k=1:D x = A*x; % population vector x day k P = [P x]; % store all the population vectors for plotting end figure days=0:D; plot(days,P) xlabel(‘days’); ylabel(‘population’) legend(‘infected people’,’fast zombies’,’slow zombies’,… ‘location’,’best’) title([‘Zombies Defeated: r = ‘ num2str(r) ‘, lambda_1 = ‘ num2str(lam1)]) xlim([0 D])end Math Statistics and Probability matlab MATH 3304 Share QuestionEmailCopy link


