The question is \'The high temperature for each month for a year (in Fahrenheit,
ID: 3750467 • Letter: T
Question
The question is '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:....'
I don't know how to write the Matlab function. Please help me.
(The studentTest function uses two sets of data)
Question 4 [15 Marks] 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 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 signmature: function [loc id max_temp] - computeMaxTemperature(file_name) Inputs file name name of the file that contains the data 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]Explanation / Answer
vector.h
#ifndef SHAPE_H
#define SHAPE_H
#include <cstdlib>
namespace mcs360
void swap(vector<T>&);
void reserve(size_t capacity);
void push_back(const T& val);
//~vector()
T& operator[](size_t V);
const T& operator[](size_t i) const;
private:
static const size_t INIT_CAPACITY = 10;
size_t current_capacity;
size_t num_items;
T* the_data;
};
template <class T>
void vector<T>::swap(mcs360::vector<T>& V)
template <class T>
T& vector<T>::operator[](size_t i)
template <class T>
void vector<T>::push_back(const T& val)
};
#endif
test_vector_class.cpp
#include <iostream>
#include "vector.h"
#include <string>
using namespace std;
int main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.