Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Setup: In this lab we will use File I/O to read and write data from a file. In this lab you will be taking in

Setup: In this lab we will use File I/O to read and write data from a file. In this lab you will be taking in characteristics of some cars and making a determination on which car ranks highest according to a specific weighting scale. USE MATLAB..

The data is stored in an Excel file called carinfo.xlsx. Your first task is to read in the data on the first sheet. The range of the data spans A2:G7 meaning there are a total of 6 cars to consider. Each row of the data is a different car and each column in the data is a different value for the car. The columns are: Make | Model | Horsepower | Torque ft-lb | Weight lb | Wheelbase in | Fuel Efficiency mpg The data is a mixture of text and numeric information. You must read in the data to get full points on your algorithm. You are NOT allowed to hard-code the values in at any point.

image text in transcribed

Part 2: Create the Structure Array Now that we have our data, the easiest format for holding the information is a structure array with fields for each of the columns from Part 1. Create the structure array and fill it with the values from the data in Part 1. There should be no nesting of the structure array and you dont need to use dynamic field names. You must store the data in a structure array form that is NOT nested to get full points on your algorithm.

Part 3: Calculating Overall Score For each car, calculate its overall score by multiplying each field by the following weight values and either adding or subtracting. Use the following formula:

Overall = (Horsepower*0.95) + (torque*0.87) (weight*0.13) + (wheelbase*0.10) + (fuelEfficiency*0.50)

Once you have calculated the overall score, add it as a field to all the cars in the structure array. You must use a loop to calculate this to get full points on your algorithm. You are NOT allowed to hardcode this for all 6 cars.

Part 4: Print to File Once we have the overall scores, print the cars information (all the fields) to an external file named results.txt. Be sure to include ALL the information for the cars. Print them in descending order based on their overall score. The highest overall score should appear first in the list. Format based on the Sample Output. You must determine the printing order using a loop and cannot convert the structure array to a table or any other format to sort the overall score. You can remove cars from the structure array when you have printed their info to the file. Dont forget to close your file when you are done writing.

Sample Output: There is no output to the command window. The output to the file should be the following:

Make: Dodge

Model: Hellcat

Overall Score: 816.46

Horsepower: 797

Torque: 707 ft-lbs

Weight: 4430 lbs

Wheelbase: 116.2 in.

Fuel Efficiency: 17.0 mpg

Make: Ford

Model: GT

Overall Score: 715.30

Horsepower: 647

Torque: 550 ft-lbs

Weight: 3054 lbs

Wheelbase: 106.7 in.

Fuel Efficiency: 17.0 mpg

Make: Dodge

Model: Viper

Overall Score: 711.56

Horsepower: 645

Torque: 600 ft-lbs

Weight: 3389 lbs

Wheelbase: 98.8 in.

Fuel Efficiency: 15.0 mpg

Make: Nissan

Model: GTR

Overall Score: 499.98

Horsepower: 600

Torque: 481 ft-lbs

Weight: 3911 lbs

Wheelbase: 109.4 in.

Fuel Efficiency: 18.0 mpg

Make: Acura

Model: NSX

Overall Score: 344.93

Horsepower: 500

Torque: 406 ft-lbs

Weight: 3878 lbs

Wheelbase: 103.5 in.

Fuel Efficiency: 21.0 mpg

Make: Toyota

Model: Supra

Overall Score: 201.27

Horsepower: 335

Torque: 365 ft-lbs

Weight: 3500 lbs

Wheelbase: 97.2 in.

Fuel Efficiency: 21.5 mpg

Fuel Efficiency mpg 21.5 18 1 Make 2 Toyota 3 Nissan 4 Ford 5 Dodge 6 Acura 7 Dodge B Model Supra GTR GT Hellcat NSX Viper Braking Horsepower (BHP) Torque ft-lbs Weight Ibs Wheel Base in 335 365 3500 600 481 3911 647 550 3054 707 4430 500 406 3878 645 600 3389 17 97.2 109.4 106.7 116.2 103.5 98.8 797 17 21 15 Fuel Efficiency mpg 21.5 18 1 Make 2 Toyota 3 Nissan 4 Ford 5 Dodge 6 Acura 7 Dodge B Model Supra GTR GT Hellcat NSX Viper Braking Horsepower (BHP) Torque ft-lbs Weight Ibs Wheel Base in 335 365 3500 600 481 3911 647 550 3054 707 4430 500 406 3878 645 600 3389 17 97.2 109.4 106.7 116.2 103.5 98.8 797 17 21 15

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions