Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

HW3

This homework assignment will help you with thefollowing learning objectives:

-      Enter external data

-      Incorporate branching into programs using if statements and switch cases

-      Incorporate looping into programs usingfor loops and while loops

-     Apply sorting algorithms

1.    You will be creating a Matlab script that will do the tasks described in #2 below.  But first, create a flowchart visually             representing #2 (only represent parts a-d in your flowchart).  You will be submitting this flowchart electronically, so please    go towww.draw.ioor use any flowchart software of your choice.  Please include a text box with your name and team number at the top.  Save your file as a .pdf or .jpg. You can also take a screen shot of your flowchart and paste it to a Word document. Do NOT submit as .xml or .html.

2.    Write a MATLAB script that will find basic statistical information of the dataset, and then use your judgment to come to a conclusion.  The script should:

a)    Display this sentence at the start of the program: “I, (Your Name), certify that I have completed this assignment in an honest manner.”

b)    Load the datasets CountryA.txt” and CountryB.txt”, posted in the Canvas organization.  The data files contain the life expectancy (in years) for two different countries, between 1950-2019.  (Data taken fromhttps://ourworldindata.org/life- expectancy).

c)    Use looping to find the mean of each dataset by adding all the elements in each dataset and then dividing by the total    number of elements (do not use the mean” or sum” commands).  Then, display the result to the screen.  When            displaying the result to the screen, display something like The mean life expectancy for Country A is __ and the mean life expectancy for Country B is __. ”

d)    Have the script find the minimum and maximum of each dataset and display it to the screen, without using the min”,

“max” , or sort” commands. You should do this using loops (Hint: create a variable that will store the min, give it an      initial value, then compare that value to all the values in the dataset) .  When displaying the result to the screen, display   something like The min life expectancy for Country A is __ and for Country B is __” and The max life expectancy for Country A is __ and for Country B is __. ”

e)    Sort each dataset into a new variable use the bubble sort to sort Country A data, and the sort” command to sort the     Country B data. Then, have the script find the median of each dataset and display it to the screen. Do not use the             “median” command, instead have the program find the median from the sorted array. Make sure the script can find the   median for a dataset with either an odd or even number of data points.  When displaying the result to the screen, display something like The median life expectancy for Country A is __ and for Country B is __.”

f)    Have the script find the variance of each dataset and display it to the screen, but do not use the var” command, instead program the equation shown below using a loop.  When displaying the result to the screen, display something like The variance for Country A is __ and for Country B is __.”

1 (xi)2

n−1

g)    Look at the results, then write your responses to the below questions as a comment at the end of your script:

•    What can you conclude about the life expectancy in Country A as compared to the life expectancy in Country B?

•    What might be some reasons for the differences?

•    Which country would you prefer to live in, and why?

Include a comment with your name at the top.

Include comments, indentation, and whitespace so that your program is neat and understandable to anyone who reads it.

This is an individual submission.  You need to submit the flowchart and the m-file.  Name your files                                                   InstructorLastName_ClassTime_HW3_YourUsername (for example, Balawejder_5pm_HW3_abc123).  Then, place your m-file and flowchart in a folder, and name your folder the same way.  Then, you will need to zip this folder.  To do this, follow these steps: (1) Right click on the folder, go to Send to”, then Compressed (zipped) folder” (see Image 1), (2) Name your zipped folder the same   way you named your regular folder (InstructorLastName_ClassTime_HW3_YourUsername), and submit your zipped folder at the    start of class through the assignment link in your section’s Canvas site.

 

Image 1