writetimetable

Writes a timetable to a delimited text file.

Category: Language Fundamentals > Data Types

Syntax

writetimetable(TT, filename)

Writes TT to filename, with the row times as the first column.

Description

The row times are written first, under the name of the time dimension (Time by default), followed by the data variables. Datetimes are written in a readable date format.

Use readtimetable to read the file back; it recognizes the first column as the row times.

Input arguments

TT
The timetable to write.
filename
Output file name, as text.

Example

Save a timetable

TT = timetable(datetime(2024,1,1) + days(0:1)', [10; 20]);
writetimetable(TT, 'tt.csv');
type tt.csv
Output

Time,Var1
01-Jan-2024,10
02-Jan-2024,20

See also

readtimetable writetable timetable readtable