readtimeseries
create a timeseries from a file
Syntax
ts = readtimeseries(filename) ts = readtimeseries(filename, opts) ts = readtimeseries(..., Name, Value)
Arguments
- filename
name of file to read
- opts
file import options obtained by detectImportOptions
- Name, Value
Name: 'VariableNames', Value: vector of strings: extracts from the file only the data corresponding to the entered variable names.
Name: 'RowTimes', Value: duration or datetime column vector: if the filename has no time, use this property to add a time index in the timeseries.
Name: 'StartTime', duration or datetime value: pecifies the start time of the timeseries.
Name: 'TimeStep', Value: duration or calendarDuration value: time step.
Name: 'SampleRate', Value: real scalar: number of samples per second (Hz).
- ts
timeseries object.
Description
The readtimeseries function creates a timeseries from a file. Each column of file is stored in variables. If however the columns have no name, then the default variable names are used (["Time", "Var1", ..., "VarN"]). Accepted file formats are .txt, .dat or .csv.
readtimeseries detects the format file thanks to detectImportOptions function. opts contains all information on the file.
To extract only the necessary variables (columns), use ts = readtimeseries(filename, "VariableNames", value).
Examples
dt = [datetime(2022,1,10):caldays(1):datetime(2022,1,21)]'; hc = [13574; 13169; 11999; 12146; 15456; 10545; 11091; 21657; 11393; 10283; 10924; 16208]; hp = [13593; 15306; 16766; 15941; 14558; 13722; 18401; 14632; 14571; 14925; 14284; 15028]; ts = timeseries(dt, hc, hp, "VariableNames", ["Time", "HC", "HP"]); writetimeseries(ts, fullfile(TMPDIR, "data.txt")); r = readtimeseries(fullfile(TMPDIR, "data.txt"));
See also
- writetimeseries — write a timeseries to file
- timeseries — create a timeseries - table with time as index
- detectImportOptions — structure containing all useful information to import the file
Report an issue | ||
<< readtable | Timeseries/Table | retime >> |