Setting up time and date
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Maaz Madha
el 20 de En. de 2021
Comentada: Cris LaPierre
el 20 de En. de 2021
Hi
I'm trying to set up a date and time where it reads from 1:00 today(as in today the time function not today today) till 00:30 tomorrow in consecutives of 30 minutes(half an hour).
%%To determine low load hours and high load hours for valley filling%%
clc
clear
example=xlsread('demand.xlsx');
load=example(:,1);
% t1.Format=('today,1:00')
% t2.Format=('tomorrow,00:30')
datetime.InputFormat('default','yyyy-MM-dd hh:mm:ss') %idk how to do this sorry
t1 = datetime('today,1:00:00');
t2 = datetime('tomorrow,00:30:00');
% t1 = datetime(2020,1,1,1,0,0);
% t2 = datetime(2020,1,2,00,30,0);
%t=t1.Format:hours(0.5):t2.Format;
datetime1=datenum(t);%convert it into strings
ts=datetime1*24*60*60;
ts1=zeros(48,1);%preallocation k1=zeros(48,1);
ts2=zeros(48,1);
figure(1)
b=plot(ts,load)
% figure(1)
% a=plot(k,load)%%plotting power with regards to k
delta_y=diff(load);%finding difference between one point from another
delta_x=diff(ts);%difference k
delta_x=delta_x';
slope=delta_y/delta_x;
slope=slope(:,1); %find the gradient of the demand to see where load is
%increasing or decreasing
for k=1:length(slope)
if sign(slope(k))==-1 %%when load is decreasing
d(k)=(slope(k));
if d(k)~=0%removing all the zeros
ts1(k)=(k);%gets the indices
end
else %%when load is increasing
e(k)=(slope(k));
if e(k)~=0%removing all the zeros
ts2(k)=k;%gets the indices for when load is increasing
end
end
end
ts1=nonzeros(ts1');%time instants
ts2=nonzeros(ts2')
I want to be able to convert the date and time(today and tomorrow with the fixed times) into seconds so it can plot the graph but also be updated everyday so the values stay relevant.
0 comentarios
Respuesta aceptada
Cris LaPierre
el 20 de En. de 2021
Editada: Cris LaPierre
el 20 de En. de 2021
Not sure I fully understand, but try this for setting up you time vector.
tVec = today('datetime')+hours(13:.5:24.5)'
Más respuestas (0)
Ver también
Categorías
Más información sobre Calendar en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!