Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Find the Area under a curve for specified values (Limits)

1 view (last 30 days)
I have a vector containing n rows (dependent on user input who gives the start and end time) and 6 columns. The first column is the time every minute and the 6th being the power at each time. I want to find the power from 08:00 to 17:00 everyday for the time defined by the user. Picture below shows this. In order to do so i found the required hours using the code shown below
DayArr = StartDateVec:minutes(1):EndDateVec;
hr = hour(DayArr);
idx(:,1) = hr>=8 & hr<17;
for the whole time period and found the rows for which i need to to extract the power values. I then chucked these required power values into another variable containing 0 for the power between 17:00 to 8:00 and the actual power values from 8:00 to 17:00 as shown below using the code
Timetable.power.*(idx(:,1))
I just need to now find the area of the power curve between these 0 values. Cumtrapz doesn't work because when the power equals 0 the value still remains the same. Any help on how I can find the cumalative power from 8-17:00 and for the remaining time the value should be 0.
I have attached the workspace for you to work with.

Answers (0)

This question is closed.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!