Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help! I need the code for this! Re-write your code using the functions outlined below. Using these cleaned-up functions re-create the graphs from Problem 3

Help! I need the code for this!

Re-write your code using the functions outlined below. Using these cleaned-up functions re-create the graphs from Problem 3 but with lines instead of plotting markers. You can change the actual function/variable names if you want, but you need to use these parameters. The first function, DiseaseStep, takes one time step. The second function, DiseaseSimulate, calls DiseaseStep nSteps times to simulate the epidemic over time. It also creates the time array (see implementation note in previous week). Splitting it up this way lets you use DiseaseStep elsewhere if need be. Having DiseaseSimulate return arrays is handy for plotting. DiseaseSimulate should call DiseaseStep. Note that you can calculate the starting N value using SStart and IStart (RStart is zero). Your script should call DiseaseSimulate once with each starting value for S (use a for loop). Todo: 1. Replace one step of the calculation with a function. Make sure it works.

functi on [ SOut, I Out, ROut ] = Di seaseSt ep( SI n, IIn, RI n, N, a, b, h )

2. Replace the simulation for loop with a function. Make sure it works.

functi on [ SvsTi me, IvsTi me, RvsTi me, ti me ] = Di seaseSi mul at e( SSt art, I St art, a, b, h, nSt eps )

3. Copy your script from problem 3 and re-write it with your DiseaseSimulate function Implementation note: Youre essentially moving the calculation part of your for loop from problem 3 into DiseaseSimulate (and splitting out the actual update step into DiseaseStep). Your for loop for this week should loop over the different starting values, getting the arrays from DiseaseSimulate and then plotting them. Use a second for loop to add the title, axes, labels, and legend to the graph. To make this work, youll need to make an array of strings (you can just copy this bit of code): titl eName = {' Suscepti bl es', 'Inf ect ed', ' Recovered', ' Tot al'}; for k = 1: 4 (l abel s, axes, l egend f or t he subpl ot) titl e(strcat(str Name{k}, ' versus ti me') ); end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions