How to apply the IF condition between the time range 4 am to 6pm of everyday of the year
3 次查看(过去 30 天)
显示 更早的评论
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
采纳的回答
Srija Kethiri
2022-2-17
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!