Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I have to create this function in matlab, any help? The data is sorted like this: with tvec being the first 6 columns of the
I have to create this function in matlab, any help?
The data is sorted like this: with tvec being the first 6 columns of the data and data being the last 4 columns
= Data aggregation function Interface function (tvec_a, data_a] aggregate_measurements (tvec, data, period) % Insert your code here Input arguments tvec: An N x 6 matrix where each row is a time vector. data: An N x 4 matrix where each row is a set of measurements. period: A string specifying how to aggregate measurements. Output arguments tvec_a: An M x 6 matrix where each row is a time vector. data_a: An M x 4 matrix with aggregated measurements. No. User input Screen output Description No. The function takes as input a matrix of time vectors tvec, a matrix of measurements data, and a string period that determines how to aggregate the measurements. The input period can take the following values: period Description 'hour' hourly consumption day' daily consumption month' monthly consumption "hour of the day' average time-of-day consumption (hourly) The outputs data_a and tvec_a contain the aggregated measurements and the corre- sponding time vectors. If period has the value 'hour'/'day'/'month', then all mea- surements recorded within the same hour/day/month are combined (summed), M is equal to the number of distinct hours/days/months during which measurements were recorded, and the rows of tvec_a identify the beginning of the M time period. If period has the value 'hour of the day' then M is equal to 24 corresponding to the 24 time invervals 00:00-01:00, 01:00-02:00, ..., 23:00-00:00, the aggregated data matrix data_a contains the average consumption over all days in these time intervals, and the matrix tvec_a identifies the start of the time intervals. 2. Aggregate data If the user chooses to aggregate data, he/she must be able to specify how to do so. As a minimum requirement, the user must have the following options: 1. Consumption per minute (no aggregation) 2. Consumption per hour 3. Consumption per day 4. Consumption per month 5. Hour-of-day consumption (hourly average) The aggregated data must be used subsequently when computing statistics and visualiz- ing data. The function must read the data from the data file filename. Each line of the data file consists of the following fields: year, month, day, hour, minute, second, zone1, zone2, zone3, zone4. All fields contain numeric values and are comma separated. Here is an example of a line from a data file: 2008,1,5,15,8,0,12.0,0.0,18.0,35.4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started