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 Ansichten (letzte 30 Tage)
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."

Antworten (1)

chicken vector
chicken vector am 20 Apr. 2023
Bearbeitet: chicken vector am 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

Kategorien

Mehr zu Time Series Events finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by