- Details
- Parent Category: Programming Assignments' Solutions
We Helped With This MATLAB Programming Assignment: Have A Similar One?

Category | Programming |
---|---|
Subject | MATLAB |
Difficulty | Undergraduate |
Status | Solved |
More Info | Differential Equations Assignment Help |
Short Assignment Requirements
Assignment Description
Objective
The assignment is designed to provide practice using functions/sub-functions to perform computations. You will also practice using repetition/loops, selections, and formatting outputs. You will develop a MATLAB program that utilizes functions/sub-functions to summarize medal standings from the Winter Olympics based on results from individual sports.
Part A
Problem and Program Details:
As a part-time blog writer for a major sports network you are tasked with providing a readerfriendly 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 , 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.
The 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 below.
Code Requirements:
1. You must use three sub-functions: the first that will compute number of gold, silver, and bronze medals per country; the second that will print the table 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).
2. primary/main function of the assignment should have the following outline:
function [] = assign4_<_445673>()
%load olympics.mat file load('olympics.mat');
% compute medals for each country using a sub-function that is
% called using a loop over all countries
% display medal counts for all countries using a sub-function
% display countries with most medals, most gold medals, >=20 medals % using a sub-function, the same sub-function should be used 3 times
end %this end terminates the function
3. You must use the fprintf statement to display your results to the command window.
4. Do not use the table function to display your results.
Hints
1. In Matlab, load the olympics.mat and see how the data is stored.
2. Do not display results for the XXX “country”, which is included in the olympics.mat file. It may be more straightforward to calculate the medal totals for the XXX "country" initially, and when displaying the results exclude it from being displayed.
3. 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.
4. In the third sub-function, you may want to use switch statement to select between different criteria.
5. You must duplicate the shown below output, including spacing and formatting, and provide
the data for the remaining countries. The “...” denotes the part of the report that you have to fill in.
Country Gold Silver Bronze Total
AUS 2 1 0 3
AUT 4 6 6 16 ...
Countries with the most medals: ...
Countries with the most gold medals: ...
Countries with at least 20 medals: CAN GER ...