Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.1.0 - Français


readtimeseries

create a timeseries from a file

Syntax

ts = readtimeseries(filename)
ts = readtimeseries(filename, opts)
ts = readtimeseries(..., OptionName, Value)

Arguments

filename

name of file to read

opts

file import options obtained by detectImportOptions

Optional pairs OptionName, Value are:

"VariableNames", vector of strings

extracts from the file only the data corresponding to the entered variable names.

"RowTimes", duration or datetime column vector

if the filename has no time, use this property to add a time index in the timeseries.

"StartTime", duration or datetime value

specifies the start time of the timeseries.

"TimeStep", duration or calendarDuration value

time step.

"SampleRate", real scalar

number of samples per second (Hz).

"ConvertTime", function

function to apply on the column specified with RowTimes. It converts the data. For example: to convert to seconds with seconds function.

ts

output argument - 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

History

VersionDescription
2024.0.0 Introduction in Scilab.
Report an issue
<< readtable Timeseries/Table removevars >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu May 22 12:54:31 CEST 2025