Objectives:
- Be able to create a MATLAB program to solve a problem
- Be able to use global variables when necessary
- Be able organize data using structure arrays
- Be able to work with large files
- Be able to use dialog boxes
Due Date/Time:
This lab is due at the beginning of class on Lesson 30 (Thursday/Friday, April 10/11). A late penalty accrues at a rate of 25% for each 24-hour period (including weekends) past the on-time turn-in date and time. The late penalty is a cap on the maximum grade that may be awarded for the late work. Thus zero points will be awarded for a programming exercise submitted 72 hours or more late. There is no early turn-in bonus for this assignment.
Help Policy:
AUTHORIZED RESOURCES:
Any, except another cadet’s program.
NOTES:
Never copy another person’s work and submit it as your own.
You must document all help received from sources other than your instructor.
DFCS will recommend a course grade of F for any cadet who egregiously violates this Help Policy or contributes to a violation by others.
You must document all help received from any source other than your instructor.
The documentation statement must explicitly describe WHAT assistance was provided, WHERE on the assignment the assistance was provided, and WHO provided the assistance.
If no help was received on this assignment, the documentation statement must state “NONE.”
Vague documentation statements must be corrected before the assignment will be graded, and will result in a 5% deduction on the assignment.
Problem Overview:
The biggest change to the Air Force lifestyle in 2004 was the introduction of the new Fit To Fight fitness program. This program requires all airmen to exercise regularly and sets high standards for fitness testing. The Fit to Fight program requirements and fitness assessment score charts are described in AFI 10-248 which became effective on 1 January 2004. The new fitness assessment includes 4 components: a 1.5 mile run, sit ups, push ups, and measurement of an individual's abdominal circumference. Based on an airman's sex, age, and performance in each of these areas, they receive a composite fitness score of up to 100 points. Based on their composite score, an airman is assigned a fitness level as shown below.
composite score | fitness level |
< 70 | poor |
70 - 74.99 | marginal |
75-89.99 | good |
≥ 90 | excellent |
Airmen that score at the good or excellent fitness levels test once per year. Airmen that score at the marginal or poor fitness levels must test more often and take measures to improve their fitness level.
For programming exercise 3 you will write a MATLAB program that reads in a file containing actual 2004 results from the Air Force fitness program and then allows the user to display information about the input data.
A fitness data file is a text file named Fitness_Data*.txt, in which the * represents zero or more valid file name characters. Each row in a fitness data file consists of one test record. Each test record has 12 data fields which represent the airman's:
age
gender (M = male, F = female)
abdominal circumference (to nearest half inch)
abdominal circumference points (0-30)
run time in seconds
run time (aerobic component) points (0-50)
number of pushups completed in 1 minute
pushup points (0-10)
number of crunches completed in 1 minute
crunch points (0-10)
composite score (0-100)
fitness level (poor, marginal, good, or excellent)
Look at Fitness_Data_10.txt for an example of a fitness data file with just 10 records.
Your program will input data from all records in a user-selected fitness data file, store the input data in a single structure array, and then allow the user to repeatedly select one of the following ten data display options:
a pie chart showing the percentages of male and female records
a histogram showing the combined (male and female) distribution of ages
a pie chart showing the percentages of males with poor, marginal, good and excellent fitness levels
a pie chart showing the percentages of females with poor, marginal, good and excellent fitness levels
a pie chart showing the percentages of all airmen with poor, marginal, good and excellent fitness levels
a histogram showing the combined (male and female) distribution of composite fitness scores in the data file
a bar chart showing the average pushups for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46
a bar chart showing the average crunches for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46
a bar chart showing the average run times for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46
a bar chart showing the average abdominal circumferences for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46
While there are 10 different display options, there are only 4 substantially different types display options: 1, 2&6, 3-5, and 7-10.
To gain a good understanding of how your program should behave, run pex3p.p on the fitness data test files linked below.
Specific Requirements:
Read the above Help Policy carefully and ask your instructor
if you have any questions.
Create a MATLAB program named
pex3 saved in the file pex3.m
that consists of a main program (function pex3)
and internal functions that do most of the work.
Develop your main program (function
pex3) code in conjunction with developing and testing internal
functions that carry out most of the work. Your main program
code may display the option menu and repeatedly call functions based on the
user-selection option. Your main program may not include
functions that directly input or display data.
Declare a single global variable that will
hold all input data in a structure array. Most of your internal
functions will need to use this global variable. It is appropriate to
use a global variable in this case because for large input files the
structure array will be very large and would be very inefficient to pass as
a function argument. Also, if your name your global structure array
Fitness_data, begin your
pex3 function with the command:
clear global Fitness_data
Since global variables are persistent (they continue to exist after a
function like pex3 completes), this command
is useful for deleting any old copies of your global structure array created
by prior runs of your program. Failing to use this command could
result in difficult to find errors.
clear the command window and then display your name and a program introduction
wait for the user to press enter (finish reading the introduction) before proceeding
get from the user the name of a fitness data file using the uigetfile dialog box, by default the user should be limited to file names of the form Fitness_Data*.txt
read in data you will need from all records in the user-selected data file and store them in a single structure array
repeat the following until the user selects the exit option
display a menu of display options using the listdlg dialog box
get from the user a single display option (one of the ten listed above) or the exit option
display a pie chart, histogram, or bar chart based on the user-selected option
using the waitforbuttonpress
function, close the displayed figure when the user clicks on it
Thoroughly document your code with comments including a
standard program header comment block, comment header blocks describing each
function, and comments in your code explaining it. Make sure your
program header includes a brief description of what your program does and a
description of any help you received on the assignment in accordance with
the above Help Policy.
Use descriptive names for all of your variables, constants, functions,
and dummy arguments. Make sure you are consistent in the format of
all your
names.
Make sure all of your code is properly indented. You can select all of your code and then use Smart Indent (CTRL-I) to properly indent all of your code.
Turn-in Requirements:
Submit your pex3.m file including your documentation statement in the program header block.
Helpful Hints:
Grading Information:
Proper Documentation Statement (-5 pts)?
Criteria |
Pts |
Good programming practice and design |
30 |
Standard header comment block for the file with all elements appropriately filled in |
5 |
Header comment block for each function with all elements appropriately filled in |
5 |
Appropriate commenting in the program body (section comments, variable descriptions) |
5 |
Meaningful and consistently formatted variable names |
5 |
Easy-to-read program formatting (appropriate use of spaces within lines, similar statements grouped and separated with a blank line) |
5 |
The code is grouped into appropriate sub-functions with appropriate arguments passed |
5 |
Program correctness |
70 |
Appropriate Program Introduction | 5 |
Reading required data from an input file | 7 |
Storing all input data in a single global structure arraay | 3 |
Getting the user option with appropriately configured list dialog box | 10 |
Correct implementation of options | 45 |
Totals |
100 |
Late Penalties (-25, -50, -75 -100) |
|