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 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
chicken vector
il 20 Apr 2023
Modificato: chicken vector
il 20 Apr 2023
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 Commenti
Vedere anche
Categorie
Scopri di più su Time Series Events in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!