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
- "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.
Optional pairs OptionName, Value are:
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
History
バージョン | 記述 |
2024.0.0 | Introduction in Scilab. |
Report an issue | ||
<< readtable | Timeseries/Table | removevars >> |