Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Matlab Help) Im having trouble with the following function My attempt: Is there

ID: 3595476 • Letter: #

Question

(Matlab Help) Im having trouble with the following function

My attempt: Is there a better way to approach this problem?

function hist = annualEnergy(Data, thresh);
n=[0.256 0.576 0.384 0.192 0.832 0.576 0.256 0.128 0.192];
for i = 1:n
    A= i.*7.77
    if A >2
       plot(A)
    end
end
end
I

Given

thank you in advance,

Create a function and use for loops and if statements to detemine how many times during the year that hourly energy usage stored in an array is greater than 2 kWh per hour. Do the calculation for each indvidual hour and plot the results with the time on the x-axis and the mumber of times on the y-axis.

Explanation / Answer

function hist = annualEnergy(Data, thresh)
n=[0.256 0.576 0.384 0.192 0.832 0.576 0.256 0.128 0.192];
for i = 1:n
A= i.*7.77
if A >2
plot(A)
end
end
end