-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetSimTime.m
More file actions
34 lines (30 loc) · 961 Bytes
/
setSimTime.m
File metadata and controls
34 lines (30 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [minStart,minEnd,tsVec] = setSimTime(timeStart,timeEnd)
%% Set Time and Init Condition Settings
[Y, M, D, H, MN, S]=datevec(timeStart,'HH:MM');
sprintf('Time start: %02d:%02d:%02d', H, MN, S)
minStart=H*60+MN;
t1 = datetime(Y,M,D,H,MN,S);
[Y, M, D, H, MN, S]=datevec(timeEnd,'HH:MM');
sprintf('Time end: %02d:%02d:%02d', H, MN, S)
minEnd=H*60+MN;
t2 = datetime(Y,M,D,H,MN,S);
% WHEN CHANGE TIME START AND END, CHANGE SIMULATING DURATION according to
% number below:
changeSimulink=(minEnd-minStart)*60 % tell user to change simulink run duration to get best results
%create timestamp vec from timeStart and timeEnd
tsVec= t1:minutes(1):t2; % minute-wise
% >> t = datetime( vec );
% >> t(1)
% ans =
% datetime
% 01-Mar-2018 00:00:00
% >> t(end)
% ans =
% datetime
% 31-Mar-2018 23:55:00
% timeStart='9:00'; % HH:MM
%
% DateStrings = {'2014-05-26';'2014-08-03'};
% t = datetime(DateStrings,'InputFormat','yyyy-MM-dd')
%
end