how to create a time series from an excel data sheet containing hourly load in 1095 rows and 23 columns. no date or time in the excel data file.
2 次查看(过去 30 天)
显示 更早的评论
So I have this file containing data in 1095 rows corresponding to each day for three years and 24 columns corresponding to each hour of the day. I want to create a time series from the data.
load_data = xlsread('loadthree.xlsx');
start_date = datetime(2018,1,1);
hourly_increment = hours(1);
datetime_vec = start_date:hourly_increment:start_date+hours(size(load_data,1)-1);
load_vec = reshape(load_data, [], 1);
load_ts = timeseries(load_vec, datetime_vec, 'Name', 'Load Data');
%gives me the error "Error using timeseries/init
The second argument must be either the time vector or the time series name."
0 个评论
回答(1 个)
chicken vector
2023-4-20
编辑:chicken vector
2023-4-20
According to the documentation, timeseries has to be either a scalar or a vector of scalars, therefore you can't use datetime.
This should be close to what you want:
% Input data:
load_data = xlsread('loadthree.xlsx');
start_date = datetime(2018,1,1);
load_vec = reshape(load_data, [], 1); % Or load_data(:)
% Time vector:
datetime_vec = 1:length(load_vec);
% Timeseries:
load_ts = timeseries(load_vec, datetime_vec, 'Name', 'Load Data');
load_ts.TimeInfo.Units = 'hour';
load_ts.TimeInfo.startDate = start_date;
load_ts.plot
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Events 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!