This example shows how to export a dataset array from the MATLAB® workspace to a text or spreadsheet file.
Load sample data.
The dataset array has 100 observations and 7 variables.
Export to a text file.
Export the dataset array,
hospital, to a
text file named
hospital.txt. By default,
to a tab-delimited text file with the same name as the dataset array,
This creates the file
hospital.txt in the
current working folder, if it does not previously exist. If the file
already exists in the current working folder,
the existing file.
By default, variable names are in the first line of the text file. Observation names, if present, are in the first column.
Export without variable names.
hospital with variable names suppressed
to a text file named
There are no variable names in the first line of the created
Export to a comma-delimited format.
hospital to a comma-delimited text
Export to an Excel spreadsheet.
hospital to an Excel® spreadsheet
By default, the first row of
variable names, and the first column has observation names.