Question: Define a local function MaxMinEnergy according to the criteria below. The function should take in one input, EnergyByMonth, and return four outputs MaxEnergy, MaxMonth, MinEnergy,

Define a local function MaxMinEnergy according to the criteria below. The function should take in one input, EnergyByMonth, and return four outputs MaxEnergy, MaxMonth, MinEnergy, and MinMonth. Remember, local functions are defined at the bottom of your script.
a. Calculate a variable MaxEnergy as the maximum value for a given input EnergyByMonth.
b. Calculate a variable MinEnergy as the minimum value for a given input EnergyByMonth.
c. Now that you have determined MaxEnergy, calculate a logical vector tempMaxIdx where all values are false except for a single true value where MaxEnergy occurs in the EnergyByMonth vector. For example, if MaxEnergy occurs at the 4th position in the EnergyByMonth vector, then the resulting logica vector would be 000100000000. HINT: use a relational operator to calculate tempMaxIdx where EnergyByMonth is equal to MaxEnergy.
d. Repeat the step above to calculate tempMinldx where all values are false except for a single true value where MinEnergy occurs in the EnergyByMonth vector.
e. Create a variable Month that is a vector that starts at 1 and steps by 1 up to 12.
f. Calculate a variable MaxMonth by indexing the Month variable with the tempMaxIdx variable.
g. Repeat the step above to calculate a variable MinMonth by indexing the Month variable with the tempMinIdx variable.
h. All calculations should be suppressed.
i. Use the fprintf function to create the text below when the MaxMinEnergy function is called, i.e. the fprintf statement should be inside your function definition. Note, the highlighted text is dynamic so it should change as the variables change. Note the different formats and decimal places of the dynamic texts. Note, there are no "new lines" (??
) in the text below; it is one continuous line.
The maximum energy used was 3150kWh in month 2, and the minimum energy used was 1250kWh in month 6
 Define a local function MaxMinEnergy according to the criteria below. The

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!