How to apply the IF condition between the time range 4 am to 6pm of everyday of the year
3 views (last 30 days)
Show older comments
Ritika Srinivasan
on 7 Feb 2022
Answered: Srija Kethiri
on 17 Feb 2022
Hi ,
I am trying to check the load requirement within a certain time range. I have one table with dates and hourly time value in the following format :
01.01.2021 00:00 and the corresponding pv production value for one year. I want to run a loop to check if the values between 4 am and 18:00 pm of each day of the year are greater than 5 or not. I would much appreciate any help
Best Regards,
Ritika
1 Comment
Accepted Answer
Srija Kethiri
on 17 Feb 2022
Hi Ritika,
To apply the if condition between time range of 4am to 6am for everyday of the year.
You can use the below code
%Data is stored in the table T
%Convert the table into a cell array
A = table2array(T);
%Split the array A with the delimiter space
D = split(A);
%By using the for loop go through the data D and check whether the condition is satisfied or not
%If the condition is satisfied store it in dataTable
j=0;
for i=1:height(T)
if(f(i,2)>=”04:00” && f(i,2)<=”18:00”)
dataTable(j,1) = T(i,1);
j++;
end
end
% The required answer is stored in dataTable.
For more information about table2array refer this link:
For more information about split function refer this link:
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!