N3 1100 sets starting value of n n4 1600 sets

This preview shows page 11 - 15 out of 20 pages.

N(3,:) = 1100;%Sets starting value of NN(4,:) = 1600;%Sets starting value of NN(5,:) = 2100;%Sets starting value of N%Output variables to plot%%Call Function[SStart,RStart,IStart,time] = DiseaseSimulate(SStart, IStart, RStart, a, b,h, N, nsteps);time1 = linspace(0,7,141);%New time variable to match array size ofother variables%times when maxes occur on the infected plottimemax1 = time1(1);timemax2 = time1(10);timemax3 = time1(12);timemax4 = time1(13);timemax5 = time1(14);
Week 5 HomeworkENGR 112Fzero while%%Call Function[peakIvalue1,peakIvalue2,peakIvalue3,peakIvalue4,peakIvalue5] =IsEpidemic(IStart);%Setting up new values for S to plotS1 = SStart(1,:);S2 = SStart(2,:);S3 = SStart(3,:);S4 = SStart(4,:);S5 = SStart(5,:);%Plotting Values of S onto the graphsubplot(1,4,1)plot(time1, S1,"-b","LineWidth",2)holdonplot(time1, S2,"-r","LineWidth",2)holdonplot(time1, S3,"-g","LineWidth",2)holdonplot(time1, S4,"-k","LineWidth",2)holdonplot(time1, S5,"-c","LineWidth",2)%Labels, Titles, Legends, & Limits for S graphxlabel("Time")ylabel("Number of People")title("Susceptible vs Time")legend("Start S=0","Start S=500","Start S=1000","Start S=1500","StartS=2000")xlim([0,7])ylim([0,2000])%Setting up new values for I to plotI1 = IStart(1,:);I2 = IStart(2,:);I3 = IStart(3,:);I4 = IStart(4,:);I5 = IStart(5,:);%Plotting Functions for I graphsubplot(1,4,2)plot(time1, I1,"-b","LineWidth",2)holdonplot(time1, I2,"-r","LineWidth",2)holdonplot(time1, I3,"-g","LineWidth",2)holdonplot(time1, I4,"-k","LineWidth",2)holdonplot(time1, I5,"-c","LineWidth",2)holdon
Week 5 HomeworkENGR 112Fzero while%Plotting where Infected is at maximumplot(timemax1,peakIvalue1,"kx","MarkerSize",20)holdonplot(timemax2,peakIvalue2,"kx","MarkerSize",20)holdonplot(timemax3,peakIvalue3,"kx","MarkerSize",20)holdonplot(timemax4,peakIvalue4,"kx","MarkerSize",20)holdonplot(timemax5,peakIvalue5,"kx","MarkerSize",20)%Labels, Titles, Legends, & Limits for I graphxlabel("Time")ylabel("Number of People")title("Infected vs Time")legend("Start S=0","Start S=500","Start S=1000","Start S=1500","StartS=2000")xlim([0,7])ylim([0,2000])%Setting up new values for R to plotR1 = RStart(1,:);R2 = RStart(2,:);R3 = RStart(3,:);R4 = RStart(4,:);R5 = RStart(5,:);%Plotting Functions for R graphsubplot(1,4,3)plot(time1, R1,"-b","LineWidth",2)holdonplot(time1, R2,"-r","LineWidth",2)holdonplot(time1, R3,"-g","LineWidth",2)holdonplot(time1, R4,"-k","LineWidth",2)holdonplot(time1, R5,"-c","LineWidth",2)%Labels, Titles, Legends, & Limits for R graphxlabel("Time")ylabel("Number of People")title("Recovered vs Time")legend("Start S=0","Start S=500","Start S=1000","Start S=1500","StartS=2000")xlim([0,7])ylim([0,2000])
Week 5 HomeworkENGR 112Fzero while%Setting up new values for N to plotN1 = N(1,:);N2 = N(2,:);N3 = N(3,:);N4 = N(4,:);N5 = N(5,:);%Plotting Functions for N graphsubplot(1,4,4)plot(time1, N1,"-b","LineWidth",2)holdonplot(time1, N2,"-r","LineWidth",2)holdonplot(time1, N3,"-g","LineWidth",2)holdonplot(time1, N4,"-k","LineWidth",2)holdonplot(time1, 55,"-c","LineWidth",2)%Labels, Titles, Legends, & Limits for N graphxlabel("Time")ylabel("Number of People")title("Total vs Time")legend("Start S=0","Start S=500","Start S=1000","Start S=1500","StartS=2000")xlim([0,7])ylim([0,2000])%Printing Functionsfprintf("Start S=0, Ending S=%0.0f, I=%0.0f, R=%0.0f, total=%0.0f\n",SStart(701),IStart(701),RStart(701),N(701))fprintf("Start S=0, Ending S=%0.0f, I=%0.0f, R=%0.0f, total=%0.0f\n",SStart(702),IStart(702),RStart(702),N(702))fprintf("Is epidemic, time %0.4f days, number of people:%0.0f\n"

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 20 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Winter
Professor
Staff
Tags
fprintf, xlabel, Closure, First class function

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture