create a timeseries from a file
ts = readtimeseries(filename) ts = readtimeseries(filename, opts) ts = readtimeseries(..., OptionName, Value)
name of file to read
file import options obtained by detectImportOptions
Optional pairs OptionName, Value are:
extracts from the file only the data corresponding to the entered variable names.
if the filename has no time, use this property to add a time index in the timeseries.
specifies the start time of the timeseries.
time step.
number of samples per second (Hz).
function to apply on the column specified with RowTimes. It converts the data. For example: to convert to seconds with seconds function.
output argument - timeseries object.
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).
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")); | ![]() | ![]() |
| Version | Description |
| 2024.0.0 | Introduction in Scilab. |