ENGR 1181 | MATLAB 11: Synthesis 1MAT_11D_Snythesis_1_Assignment

Follow the format that you’ve been doing for previous problems.

·  Do the entire problem in one script file.

·  Your script file should include comment statements to help organize your script file.

·  Make sure the Command Window displays your name, the assignment name, and your group number.

·  Submit based on your instructor’s guidelines.

Background

The purpose of this assignment is to gain experience combining the elements that have been learned in prior classes to solve a problem.

Define

In this assignment you are to write a program that will prompt the user to enter data in the command window, store the data into vectors, and perform calculations on the data.

The data that will be entered from the command window given in Table 1, below. You can choose how you want the user to enter the data and how you want it to be stored, but there should be vectors or a matrix used. The years do not need to be stored into a vector if you choose not to; they can be determined by manipulating the vector indices (for example index position 1 corresponds to 2000, index position 6 corresponds to 2005, etc.).

For all of the tasks below do NOT use the functions sum(), mean(), max() or min().

Table 1: Tour de France data for years 2000 to 2005*

Year / Number of Stages / Winner’s Avg Speed (km/h)
2000 / 21 / 39.556
2001 / 20 / 40.020
2002 / 20 / 39.930
2003 / 20 / 40.940
2004 / 20 / 40.553
2005 / 21 / 41.654

*This table includes speeds from Lance Armstrong

Instructions

Represent

·  From the algorithm for finding the maximum shown at the end of the document, create a flowchart. Turn in as Part 1 to Carmen Dropbox.

Plan

·  Create a script file and add appropriate header information.

·  Outline the steps your program will take by adding comment statements to your script file based on the pseudocode.

Implement

·  Write a script file to perform the following tasks:

-  Prompt the user to enter into the command window the information from the table (This should use the input() command)

-  Store the data into a couple vectors or a matrix.

-  Find the minimum and maximum winner’s average speeds and their corresponding year and print the results to the screen using fprintf() (display speeds in km/h).

-  Compute the average of the winner’s average speeds and print it to the screen in both km/h and mph using fprintf().

-  Find the number of tours that had 20 stages and the number of tours that had 21 stages and display these values using fprintf(), making sure that they are properly labeled.

Evaluate

·  Perform a calculation to verify and check your results.

Document

·  Print (paper or pdf depending on instructor preference) the final version of your script file.

·  Print (paper or pdf depending on instructor preference) the command window output.

·  Print (paper or pdf depending on instructor preference) the calculation for the evaluate step.

·  If paper: Staple the planning documentation, script file, output, and verification together and turn it in.

·  If pdf: Combine pdf files together and submit to Carmen Dropbox.

Algorithm for finding a maximum:

Assumptions: Winner’s average speed data is loaded into a vector called Speed.

1)  Set a temporary variable temp_max, to be equal to the first element of the vector, Speed(1). Set a temporary variable index_max to be equal to 1.

2)  Set up the for loop to start at i=1 and go until i = length(Speed)

3)  If Speed(i) > temp_max go to step 4, otherwise go to step 6

4)  Set temp_max=Speed(i)

5)  Set index_max=i;

6)  End the for loop and repeat until stop condition is reached, then go to step 7

7)  Display using fprintf() the maximum value, temp_max with units