How to apply the IF condition between the time range 4 am to 6pm of everyday of the year

4 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Srija Kethiri
Srija Kethiri am 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:

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by