Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a matlab function The high temperature for each month for a year (in Fahrenheit, rounded to integers) for different locations are stored in a

Write a matlab function

The high temperature for each month for a year (in Fahrenheit, rounded to integers) for different locations are stored in a file. Each line of the file has a location ID, followed by 12 temperatures. For example, the file might store:

432 33 37 42 45 53 72 82 79 66 55 46 41

777 29 33 41 46 52 66 77 88 68 55 48 39

567 55 62 68 72 75 79 83 89 85 80 77 65

The value on the first field in each row (432, 777 and 567 in this example) is a location ID. The 12 numbers that follow the location ID are the high temperatures for the months. Write a Matlab function computeMaxTemperature, that will take the filename as an input argument, compute the maximum temperature for each location, and return two row vectors: the first vector must contain the location IDs in the same order they appear in the file; and the second vector must contain the top temperature for each location (the same order as the locations). You must use the computeMatrixMax function from the previous example. If the specified file does not exist, the function must return -1 for both the location ID and the maximum temperature. If the specified file exists, you can assume that the data in the file has the correct format. Your function will have the following signature:

function [loc_id max_temp] = computeMaxTemperature(file_name)

Inputs: file_name - name of the file that contains the data. There has two file name data1.dat and data2.dat

Output: loc_id - 1 x N vector with location IDs, in the same order they appear in the file - N is the number of rows in the file

-1 if the file does not exist

max_temp - 1 x N vector that contains the maximum temperature for each location

-1 if the file does not exist

In the above example, if the file specified above was given as the input file name, the output must be:

loc_id = [432 777 567]

max_temp = [82 88 89]

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

product cost and period cost formuale

Answered: 1 week ago