Skip to Main Content Skip to Search
Product Documentation

Data Import and Export

File Opening, Loading, and SavingOpen files; transfer data between files and MATLAB workspace
Text FilesDelimited or formatted I/O to text files
SpreadsheetsExcel and Lotus 1-2-3 files
Low-Level File I/ORead and write operations at the byte or character level
ImagesGraphics files
Scientific DataCDF, FITS, HDF formats
Audio and VideoRead and write audio and video, record and play audio
XML DocumentsDocuments written in Extensible Markup Language
Memory MappingAccess file data via memory map using MATLAB array indexing
File Name ConstructionGet path, directory, filename information; construct filenames
File CompressionExtract from tar or zip file; compress and decompress files
Internet File AccessSend email, download from URL, or connect to FTP server


For a list of file formats that you can read with MATLAB®, see Supported File Formats.

File Opening, Loading, and Saving

daqreadRead Data Acquisition Toolbox (.daq) file
importdataLoad data from file
loadLoad data from MAT-file into workspace
matfileLoad and save parts of variables in MAT-files
openOpen file in appropriate application
saveSave workspace variables to file
uigetdirOpen standard dialog box for selecting directory
uigetfileOpen standard dialog box for retrieving files
uiimportOpen Import Wizard to import data
uiputfileOpen standard dialog box for saving files
uisaveInteractively save workspace variables to MAT-file
winopenOpen file in appropriate application (Windows)

Text Files

csvreadRead comma-separated value file
csvwriteWrite comma-separated value file
dlmreadRead ASCII-delimited file of numeric data into matrix
dlmwriteWrite matrix to ASCII-delimited file
filereadRead contents of file into string
textreadRead data from text file; write to multiple outputs
textscanRead formatted data from text file or string
typeDisplay contents of file

Spreadsheets

Microsoft ExcelRead and write Microsoft Excel spreadsheet
Lotus 1-2-3Read and write Lotus WK1 spreadsheet

Microsoft Excel

xlsfinfoDetermine whether file contains Microsoft Excel spreadsheet
xlsreadRead Microsoft Excel spreadsheet file
xlswriteWrite Microsoft Excel spreadsheet file

Lotus 1-2-3

wk1finfoDetermine whether file contains 1-2-3 WK1 worksheet
wk1readRead Lotus 1-2-3 WK1 spreadsheet file into matrix
wk1writeWrite matrix to Lotus 1-2-3 WK1 spreadsheet file

Low-Level File I/O

fcloseClose one or all open files
feofTest for end-of-file
ferrorInformation about file I/O errors
fgetlRead line from file, removing newline characters
fgetsRead line from file, keeping newline characters
fopenOpen file, or obtain information about open files
fprintfWrite data to text file
freadRead data from binary file
frewindMove file position indicator to beginning of open file
fscanfRead data from text file
fseekMove to specified position in file
ftellPosition in open file
fwriteWrite data to binary file

Images

exifreadRead EXIF information from JPEG and TIFF image files
im2javaConvert image to Java image
imfinfoInformation about graphics file
imreadRead image from graphics file
imwriteWrite image to graphics file
TiffMATLAB Gateway to LibTIFF library routines

Scientific Data

Common Data FormatWork with CDF files
Network Common Data FormWork with netCDF files
Flexible Image Transport SystemWork with FITS files
Hierarchical Data FormatWork with HDF files
Band-Interleaved DataWork with band-interleaved files

Common Data Format

High-level I/O Functions

cdfepochConvert MATLAB formatted dates to CDF formatted dates
cdfinfoInformation about Common Data Format (CDF) file
cdfreadRead data from Common Data Format (CDF) file
cdfwriteWrite data to Common Data Format (CDF) file
todatenumConvert CDF epoch object to MATLAB datenum

Library Information

cdflibSummary of Common Data Format (CDF) capabilities
cdflib.getConstantNames Names of Common Data Format (CDF) library constants
cdflib.getConstantValue Numeric value corresponding to Common Data Format (CDF) library constant
cdflib.getFileBackwardReturn current backward compatibility mode setting
cdflib.getLibraryCopyright Copyright notice of Common Data Format (CDF) library
cdflib.getLibraryVersion Library version and release information
cdflib.getValidate Library validation mode
cdflib.setFileBackwardSet backward compatibility mode
cdflib.setValidate Specify library validation mode

File Operations

cdflib.closeClose Common Data Format (CDF) file
cdflib.createCreate Common Data Format (CDF) file
cdflib.deleteDelete existing Common Data Format (CDF) file
cdflib.getCacheSize Number of cache buffers used
cdflib.getChecksum Checksum mode
cdflib.getCompression Compression settings
cdflib.getCompressionCacheSize Number of compression cache buffers
cdflib.getCopyright Copyright notice in Common Data Format (CDF) file
cdflib.getFormatFormat of Common Data Format (CDF) file
cdflib.getMajority Majority of variables
cdflib.getName Name of Common Data Format (CDF) file
cdflib.getReadOnlyMode Read-only mode
cdflib.getStageCacheSize Number of cache buffers for staging
cdflib.getVersion Common Data Format (CDF) library version and release information
cdflib.inquireBasic characteristics of Common Data Format (CDF) file
cdflib.openOpen existing Common Data Format (CDF) file
cdflib.setCacheSizeSpecify number of dotCDF cache buffers
cdflib.setChecksum Specify checksum mode
cdflib.setCompression Specify compression settings
cdflib.setCompressionCacheSize Specify number of compression cache buffers
cdflib.setFormatSpecify format of Common Data Format (CDF) file
cdflib.setMajority Specify majority of variables
cdflib.setReadOnlyMode Specify read-only mode
cdflib.setStageCacheSize Specify number of staging cache buffers for Common Data Format (CDF) file

Variables

cdflib.closeVarClose specified variable from multifile format Common Data Format (CDF) file
cdflib.createVarCreate new variable
cdflib.deleteVarDelete variable
cdflib.deleteVarRecordsDelete range of records from variable
cdflib.getVarAllocRecordsNumber of records allocated for variable
cdflib.getVarBlockingFactorBlocking factor for variable
cdflib.getVarCacheSizeNumber of multifile cache buffers
cdflib.getVarCompressionInformation about compression used by variable
cdflib.getVarDataSingle value from record in variable
cdflib.getVarMaxAllocRecNumMaximum allocated record number for variable
cdflib.getVarMaxWrittenRecNumMaximum written record number for variable
cdflib.getVarName Variable name, given variable number
cdflib.getVarNum Variable number, given variable name
cdflib.getVarNumRecsWritten Number of records written to variable
cdflib.getVarPadValuePad value for variable
cdflib.getVarRecordDataEntire record for variable
cdflib.getVarReservePercentCompression reserve percentage for variable
cdflib.getVarsMaxWrittenRecNumMaximum written record number for CDF file
cdflib.getVarSparseRecordsInformation about how variable handles sparse records
cdflib.hyperGetVarDataRead hyperslab of data from variable
cdflib.hyperPutVarDataWrite hyperslab of data to variable
cdflib.inquireVar Information about variable
cdflib.putVarDataWrite single value to variable
cdflib.putVarRecordDataWrite entire record to variable
cdflib.renameVar Rename existing variable
cdflib.setVarAllocBlockRecordsSpecify range of records to be allocated for variable
cdflib.setVarBlockingFactorSpecify blocking factor for variable
cdflib.setVarCacheSizeSpecify number of multi-file cache buffers for variable
cdflib.setVarCompressionSpecify compression settings used with variable
cdflib.setVarInitialRecsSpecify initial number of records written to variable
cdflib.setVarPadValueSpecify pad value used with variable
cdflib.SetVarReservePercentSpecify reserve percentage for variable
cdflib.setVarsCacheSizeSpecify number of cache buffers used for all variables
cdflib.setVarSparseRecordsSpecify how variable handles sparse records

Attributes and Entries

cdflib.createAttrCreate attribute
cdflib.deleteAttrDelete attribute
cdflib.deleteAttrEntryDelete attribute entry
cdflib.deleteAttrgEntryDelete entry in global attribute
cdflib.getAttrEntryValue of entry in attribute with variable scope
cdflib.getAttrgEntryValue of entry in global attribute
cdflib.getAttrMaxEntryNumber of last entry for variable attribute
cdflib.getAttrMaxgEntryNumber of last entry for global attribute
cdflib.getAttrNameName of attribute, given attribute number
cdflib.getAttrNumAttribute number, given attribute name
cdflib.getAttrScopeScope of attribute
cdflib.getNumAttrEntriesNumber of entries for attribute with variable scope
cdflib.getNumAttrgEntriesNumber of entries for attribute with global scope
cdflib.getNumAttributesNumber of attributes with variable scope
cdflib.getNumgAttributesNumber of attributes with global scope
cdflib.inquireAttr Information about attribute
cdflib.inquireAttrEntry Information about entry in attribute with variable scope
cdflib.inquireAttrgEntry Information about entry in attribute with global scope
cdflib.putAttrEntryWrite value to entry in attribute with variable scope
cdflib.putAttrgEntryWrite value to entry in attribute with global scope
cdflib.renameAttr Rename existing attribute

Utilities

cdflib.computeEpochConvert time value to CDF_EPOCH value
cdflib.computeEpoch16Convert time value to CDF_EPOCH16 value
cdflib.epoch16BreakdownConvert CDF_EPOCH16 value to time value
cdflib.epochBreakdownConvert CDF_EPOCH value into time value

Network Common Data Form

High-level I/O Functions

nccreateCreate variable in NetCDF file
ncdisp Display contents of NetCDF file in Command Window
ncinfo Return information about NetCDF file
ncreadRead data from variable in NetCDF file
ncreadatt Read attribute value from NetCDF file
ncwrite Write data to NetCDF file
ncwriteattWrite attribute to NetCDF file
ncwriteschemaAdd NetCDF schema definitions to NetCDF file

Library Functions

netcdf.setChunkCache Set default chunk cache settings for NetCDF library
netcdfSummary of MATLAB Network Common Data Form (NetCDF) capabilities
netcdf.getChunkCache Retrieve chunk cache settings for NetCDF library
netcdf.inqLibVersReturn netCDF library version information
netcdf.setDefaultFormatChange default netCDF file format

File Operations

netcdf.abortRevert recent netCDF file definitions
netcdf.closeClose netCDF file
netcdf.createCreate new NetCDF dataset
netcdf.endDefEnd netCDF file define mode
netcdf.inq Return information about netCDF file
netcdf.inqFormat Determine format of NetCDF file
netcdf.inqGrps Retrieve array of child group IDs
netcdf.inqUnlimDimsReturn list of unlimited dimensions in group
netcdf.openOpen netCDF file
netcdf.reDefPut open netCDF file into define mode
netcdf.setFillSet netCDF fill mode
netcdf.syncSynchronize netCDF file to disk

Dimensions

netcdf.defDimCreate netCDF dimension
netcdf.inqDimReturn netCDF dimension name and length
netcdf.inqDimIDReturn dimension ID
netcdf.renameDimChange name of netCDF dimension

Groups

netcdf.defGrpCreate group in NetCDF file
netcdf.inqDimIDsRetrieve list of dimension identifiers in group
netcdf.inqGrpName Retrieve name of group
netcdf.inqGrpNameFull Complete pathname of group
netcdf.inqGrpParent Retrieve ID of parent group.
netcdf.inqNcid Return ID of named group
netcdf.inqVarIDs IDs of all variables in group

Variables

netcdf.defVarFill Define fill parameters for NetCDF variable
netcdf.inqVarDeflateDetermine compression settings for NetCDF variable
netcdf.defVarCreate NetCDF variable
netcdf.defVarChunking Define chunking behavior for NetCDF variable
netcdf.defVarDeflateDefine compression parameters for NetCDF variable
netcdf.defVarFletcher32 Define checksum parameters for NetCDF variable
netcdf.getVarReturn data from netCDF variable
netcdf.inqVarReturn information about variable
netcdf.inqVarChunking Determine chunking settings for NetCDF variable
netcdf.inqVarFill Determine values of fill parameters for NetCDF variable
netcdf.inqVarFletcher32 Fletcher32 checksum setting for NetCDF variable
netcdf.inqVarIDReturn ID associated with variable name
netcdf.putVarWrite data to netCDF variable
netcdf.renameVarChange name of netCDF variable

Attributes

netcdf.copyAttCopy attribute to new location
netcdf.delAttDelete netCDF attribute
netcdf.getAttReturn netCDF attribute
netcdf.inqAttReturn information about netCDF attribute
netcdf.inqAttIDReturn ID of netCDF attribute
netcdf.inqAttNameReturn name of netCDF attribute
netcdf.putAttWrite netCDF attribute
netcdf.renameAttChange name of attribute

Utilities

netcdf.getConstantReturn numeric value of named constant
netcdf.getConstantNamesReturn list of constants known to netCDF library

Flexible Image Transport System

fitsinfoInformation about FITS file
fitsreadRead data from FITS file

Hierarchical Data Format

h5createCreate HDF5 data set
h5disp Display contents of HDF5 file
h5info Return information about HDF5 file
h5read Read data from HDF5 data set
h5readatt Read attribute from HDF5 file
h5writeWrite to HDF5 data set
h5writeatt Write HDF5 attribute
hdfSummary of MATLAB HDF4 capabilities
hdf5Summary of MATLAB HDF5 capabilities
hdf5infoInformation about HDF5 file
hdf5readRead HDF5 file
hdf5writeWrite data to file in HDF5 format
hdfinfoInformation about HDF4 or HDF-EOS file
hdfreadRead data from HDF4 or HDF-EOS file
hdftoolBrowse and import data from HDF4 or HDF-EOS files

Band-Interleaved Data

multibandreadRead band-interleaved data from binary file
multibandwriteWrite band-interleaved data to file

Audio and Video

Reading and Writing FilesInput/output data to audio and video file formats
Recording and PlaybackRecord and listen to audio
UtilitiesConvert audio signal

Reading and Writing Files

aufinfoInformation about NeXT/SUN (.au) sound file
aureadRead NeXT/SUN (.au) sound file
auwriteWrite NeXT/SUN (.au) sound file
avifileCreate new Audio/Video Interleaved (AVI) file
aviinfoInformation about Audio/Video Interleaved (AVI) file
avireadRead Audio/Video Interleaved (AVI) file
mmfileinfoInformation about multimedia file
mmreaderCreate object for reading video files
movie2aviCreate Audio/Video Interleaved (AVI) file from MATLAB movie
VideoReaderRead video files
VideoWriterWrite video files
wavfinfoInformation about WAVE (.wav) sound file
wavreadRead WAVE (.wav) sound file
wavwriteWrite WAVE (.wav) sound file

Recording and Playback

audiodevinfoInformation about audio device
audioplayerCreate object for playing audio
audiorecorderCreate object for recording audio
soundConvert matrix of signal data to sound
soundscScale data and play as sound
wavplayPlay recorded sound on PC-based audio output device
wavrecordRecord sound using PC-based audio input device

Utilities

beepProduce beep sound
lin2muConvert linear audio signal to mu-law
mu2linConvert mu-law audio signal to linear

XML Documents

xmlreadRead XML document and return Document Object Model node
xmlwriteWrite XML Document Object Model node
xsltTransform XML document using XSLT engine

Memory Mapping

disp (memmapfile)Information about memmapfile object
get (memmapfile)Memmapfile object properties
memmapfileConstruct memmapfile object

File Name Construction

filemarkerCharacter to separate file name and internal function name
filepartsParts of file name and path
filesepFile separator for current platform
fullfileBuild full file name from parts
tempdirName of system's temporary folder
tempnameUnique name for temporary file

File Compression

gunzipUncompress GNU zip files
gzipCompress files into GNU zip files
tarCompress files into tar file
untarExtract contents of tar file
unzipExtract contents of zip file
zipCompress files into zip file

Internet File Access

FTPConnect to FTP server
sendmailSend email message to address list
urlreadDownload URL content to MATLAB string
urlwriteDownload URL content and save to file
  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS