Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The data file given is olympics.mat From the file we get four variables: bronze, countries, gold, and silver They contain the following listed info when

image text in transcribedimage text in transcribed

The data file given is olympics.mat

From the file we get four variables: bronze, countries, gold, and silver

They contain the following listed info when entered into Matlab. Data is not in a table i am using table for convenience purposes to show data.

bronze countries gold silver

873 char array

'SWE' 'NOR' 'USA' 'USA' 'SUI' 'CZE' 'AUT' 'USA' 'AUT' 'SWE' 'CRO' 'FRA' 'SVK' 'XXX' 'XXX' 'RUS' 'FRA' 'FRA' 'GER' 'BLR' 'GER' 'RUS' 'CAN' 'USA' 'NOR' 'CZE' 'SWE' 'SWE' 'RUS' 'CZE' 'SLO' 'NOR' 'POL' 'FIN' 'RUS' 'FIN' 'SUI' 'CHN' 'JPN' 'CAN' 'GER' 'RUS' 'USA' 'CHN' 'NOR' 'USA' 'CHN' 'FRA' 'FIN' 'FIN' 'ITA' 'GER' 'GER' 'AUT' 'ITA' 'GER' 'CAN' 'USA' 'USA' 'USA' 'ITA' 'KOR' 'KOR' 'USA' 'RUS' 'GER' 'AUT' 'AUT' 'NOR' 'USA' 'FRA' 'FRA' 'USA' 'AUT' 'SUI' 'JPN' 'USA' 'NOR' 'RUS' 'NED' 'NED' 'CHN' 'NED' 'CZE' 'CAN' 'CAN' 'POL'

273 char array

'AUS' 'AUT' 'BLR' 'CAN' 'CHN' 'CRO' 'CZE' 'EST' 'FIN' 'FRA' 'GBR' 'GER' 'ITA' 'JPN' 'KAZ' 'KOR' 'LAT' 'NED' 'NOR' 'POL' 'RUS' 'SLO' 'SUI' 'SVK' 'SWE' 'USA' 'XXX'

873 char array

'ITA' 'SUI' 'NOR' 'SUI' 'USA' 'GER' 'GER' 'AUT' 'USA' 'GER' 'FRA' 'SWE' 'RUS' 'NOR' 'XXX' 'NOR' 'SVK' 'GER' 'GER' 'NOR' 'RUS' 'GER' 'USA' 'CAN' 'RUS' 'SUI' 'SWE' 'NOR' 'NOR' 'SWE' 'NOR' 'SWE' 'NOR' 'POL' 'GER' 'NOR' 'CAN' 'SWE' 'USA' 'KOR' 'CHN' 'CAN' 'CAN' 'BLR' 'SUI' 'USA' 'AUS' 'CAN' 'CAN' 'CAN' 'GER' 'GER' 'AUT' 'USA' 'FRA' 'AUT' 'CAN' 'KOR' 'KOR' 'CAN' 'CHN' 'CHN' 'CHN' 'CHN' 'CAN' 'GBR' 'SUI' 'SUI' 'AUT' 'USA' 'CAN' 'USA' 'AUS' 'NED' 'CAN' 'KOR' 'USA' 'NED' 'NED' 'KOR' 'CAN' 'KOR' 'CAN' 'NED' 'CZE' 'CZE' 'GER'

873 char array

'CRO' 'NOR' 'USA' 'NOR' 'CRO' 'AUT' 'SLO' 'SLO' 'USA' 'USA' 'NOR' 'AUT' 'FRA' 'NOR' 'BLR' 'AUT' 'GER' 'SVK' 'RUS' 'KAZ' 'FRA' 'GER' 'GER' 'CAN' 'RUS' 'ITA' 'GER' 'GER' 'GER' 'NOR' 'POL' 'EST' 'SWE' 'NOR' 'SWE' 'GER' 'NOR' 'CAN' 'RUS' 'JPN' 'CHN' 'USA' 'AUS' 'USA' 'AUT' 'CAN' 'CHN' 'NOR' 'USA' 'USA' 'GER' 'AUT' 'LAT' 'USA' 'USA' 'USA' 'KOR' 'KOR' 'USA' 'KOR' 'CAN' 'USA' 'KOR' 'CAN' 'LAT' 'GER' 'POL' 'POL' 'GER' 'FIN' 'AUT' 'CAN' 'USA' 'RUS' 'FRA' 'JPN' 'KOR' 'USA' 'KOR' 'RUS' 'USA' 'GER' 'NED' 'CAN' 'GER' 'GER' 'JPN'

I want ask help for Part A could I have few confusion for subfunction

ENCMP 100-Computer Programming for Engineers Page 2 of 4 Problem and Program Details: As a part-time blog writer for a major sports network you are tasked with providing a reader- friendly summary of the most recent Winter Olympics. This will be an integral part of an article that will be used to discuss the next Olympic Games. Given detailed results from the Winter Olympics, which were provided to you by your supervisor, you are asked to summarize the medal standing for all participating countries. Your input data, which is provided in the olympics.mat file that can be downloaded from the eClass/Moodle, includes the following variables: - countries, which lists countries that scored medals. The countries are coded using three letter abbreviations, e.g., CAN stands for Canada. We use country code XXX to denote a case where two countries received the same medal (silver) in the same sport, i.e., there was a tie. gold, silver and bronze, which list the countries that received gold, silver, and bronze medals, respectively. Note that the gold, silver and bronze variables list the data in the same order. This means that the ith row in these variables gives the countries that received the corresponding three types of medals for the same sport. Part A Your objective is to convert the results per sport (from the olympics.mat file) into a table that lists medal counts and total medal tally per country where countries are sorted alphabetically. Note that countries variable already lists the countries alphabetically. You should also show the best performing country (or countries in case of a tie), when scored on the total medal tally and the number of gold medals. Moreover, you are required to list the countries that have 20 or more medals. The results should be printed to the Command Window using a specific format shown in the hints section. Please refer to the skeleton posted on eClass under part A as a starting point. You must save the data in an array or vector. Part B Your objective is to convert the results per sport (from the olympics.mat file) into a table that lists medal counts and total medal tally per country where countries are sorted alphabetically. To accomplish this task, you must save your results into a structure or structure array. Note that countries variable already lists the countries alphabetically. You should also show the best performing country (or countries in case of a tie), when scored on the total medal tally and the number of gold medals. Moreover, you are required to list the countries that have 20 or more medals. The results should be printed to the Command Window using a specific format shown in the hints section. Please refer to the skeleton posted on eClass under part B as a starting point. You must save the data in a structure array. Code Requirements: 1. You must use functions/sub functions for both part A and part B, failure to do so will result in substantial mark reductions. 2. You will create at least three functions (not including the main function): the first function will compute number of gold, silver, and bronze medals for one country; the second function will print the results with medal standings; and the third that will compute and print the best performing countries. The third sub-function should be called three times; each time for a different criteria of performance (most medals, most gold medals, and at least 20 medals). 3. Posted on eClass is the outline or the skeleton code for the assignment. There will be a total of 4 functions in this one file. 4. You must use the fprintf statement to display all of your results to the command window. 5. Do not use the table function to display your results. 6. When running your solution, there is no user input other than the load command. You will be using the same olympics.mat file for both parts of the assignment. Hints 1. Don't panic, break down this problem into smaller parts that you can do. Create either pseudo code or a software flow chart to aid you in accomplishing this assignment. 2. Refer to chapter 6 - MATLAB Programs and chapter 8 Data Structures: Cell Arrays and Structures 3. In Matlab, load the olympics.mat and see how the data is stored. 4. Calculate the results for the XXX "country" but do not display results for the XXX "country", which is included in the olympics.mat file. It may be simpler when displaying the results exclude it from being displayed. 5. Note that it is possible that there is more than one country with the highest number of all medals, or highest number of gold medals, or at least 20 medals. In that case, you code should list all of these countries. 6. In the third sub-function, you may want to use switch statement to select between different criteria. ENCMP 100-Computer Programming for Engineers Page 2 of 4 Problem and Program Details: As a part-time blog writer for a major sports network you are tasked with providing a reader- friendly summary of the most recent Winter Olympics. This will be an integral part of an article that will be used to discuss the next Olympic Games. Given detailed results from the Winter Olympics, which were provided to you by your supervisor, you are asked to summarize the medal standing for all participating countries. Your input data, which is provided in the olympics.mat file that can be downloaded from the eClass/Moodle, includes the following variables: - countries, which lists countries that scored medals. The countries are coded using three letter abbreviations, e.g., CAN stands for Canada. We use country code XXX to denote a case where two countries received the same medal (silver) in the same sport, i.e., there was a tie. gold, silver and bronze, which list the countries that received gold, silver, and bronze medals, respectively. Note that the gold, silver and bronze variables list the data in the same order. This means that the ith row in these variables gives the countries that received the corresponding three types of medals for the same sport. Part A Your objective is to convert the results per sport (from the olympics.mat file) into a table that lists medal counts and total medal tally per country where countries are sorted alphabetically. Note that countries variable already lists the countries alphabetically. You should also show the best performing country (or countries in case of a tie), when scored on the total medal tally and the number of gold medals. Moreover, you are required to list the countries that have 20 or more medals. The results should be printed to the Command Window using a specific format shown in the hints section. Please refer to the skeleton posted on eClass under part A as a starting point. You must save the data in an array or vector. Part B Your objective is to convert the results per sport (from the olympics.mat file) into a table that lists medal counts and total medal tally per country where countries are sorted alphabetically. To accomplish this task, you must save your results into a structure or structure array. Note that countries variable already lists the countries alphabetically. You should also show the best performing country (or countries in case of a tie), when scored on the total medal tally and the number of gold medals. Moreover, you are required to list the countries that have 20 or more medals. The results should be printed to the Command Window using a specific format shown in the hints section. Please refer to the skeleton posted on eClass under part B as a starting point. You must save the data in a structure array. Code Requirements: 1. You must use functions/sub functions for both part A and part B, failure to do so will result in substantial mark reductions. 2. You will create at least three functions (not including the main function): the first function will compute number of gold, silver, and bronze medals for one country; the second function will print the results with medal standings; and the third that will compute and print the best performing countries. The third sub-function should be called three times; each time for a different criteria of performance (most medals, most gold medals, and at least 20 medals). 3. Posted on eClass is the outline or the skeleton code for the assignment. There will be a total of 4 functions in this one file. 4. You must use the fprintf statement to display all of your results to the command window. 5. Do not use the table function to display your results. 6. When running your solution, there is no user input other than the load command. You will be using the same olympics.mat file for both parts of the assignment. Hints 1. Don't panic, break down this problem into smaller parts that you can do. Create either pseudo code or a software flow chart to aid you in accomplishing this assignment. 2. Refer to chapter 6 - MATLAB Programs and chapter 8 Data Structures: Cell Arrays and Structures 3. In Matlab, load the olympics.mat and see how the data is stored. 4. Calculate the results for the XXX "country" but do not display results for the XXX "country", which is included in the olympics.mat file. It may be simpler when displaying the results exclude it from being displayed. 5. Note that it is possible that there is more than one country with the highest number of all medals, or highest number of gold medals, or at least 20 medals. In that case, you code should list all of these countries. 6. In the third sub-function, you may want to use switch statement to select between different criteria

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Finance questions