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.
5 ビュー (過去 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!