Matlab

Create an m-file script that does the following. Begin the file with a comment at the

top of the script. Each problem should be done in section. You will also create two

m-file functions and a txt file will be generated as an output. Upload all these files

and a published pdf of the script to the drop box.

1. First construct a function called bisect that approximates the root location

following the bisection algorithm described on slide 4. Next, UAH has 8000

students, one student returns from Spring break with a contagious flu virus. The

spread of the virus, I, is given by:

Where I is the total number of students infected after t days. The college will

cancel classes when 50% or more of the students are infected. After how many

days will the college cancel classes?

a. Compute an approximation for this value using the bisect function.

b. Compute an approximation for this value using the fzero function.

2. Hooke’s law states that the force needed to displace a spring from equilibrium is

linearly proportional to the displacement. A student set up an experiment for a

spring and recorded the displacement and saved this in a csv file called

spring.csv (this file is in the Canvas assignment). The first column refers to the

measured displacement (note negative means compression) and the second

column refers to the measured force.

a. Find the two coefficients for a linear regression fit. (Be sure to show these

values!)

b. Determine the correlation coefficient.

c. On a plot show both the data (symbols) and the “best” fit line. Include a

legend. The line should be plotted for -5 = x = 7.

2

t

e

I

0.6

1 6999

8000

?

?

?

3. Read in the data from the file fifth.csv (again found in the Canvas assignment).

It is proposed that a fifth-order polynomial fits the data. The first column

represents the independent data and the second column represents the

dependent data.

a. Find the coefficients for the polynomial that fits this data.

b. On a plot show both the data (symbols) and the “best” 5rh order

polynomial. Include a legend. The line should be plotted for -5 = x = 5.

4. Construct an m-file function mom that follows the flow diagram for the

algorithm shown on slide 5. Notice that the output is given not to the screen but

into a file called output.txt and also has a given structure (see slide 6). In your

script call this function with the following inputs:

x = [1 3 2 5 3 3 7 4 3 4 5 8 2]

r = 4

name = ‘Your name here’

(Hint: for the average simply use the mean(x) that is in

MATLAB already)

PLACE THIS ORDER OR A SIMILAR ORDER WITH US TODAY AND GET A GOOD DISCOUNT