Working with Spreadsheets
You can use MATLAB to import and export data to the following types of spreadsheets:
Microsoft Excel Spreadsheets
This section covers
xlsread reference pages for more detailed information and examples.
Getting Information About the File
xlsfinfo function to determine if a file contains a readable Microsoft Excel spreadsheet.
'Microsoft Excel Spreadsheet'if the file contains an Excel worksheet readable with the
xlsreadfunction. Otherwise, it contains an empty string (
Example -- Querying an XLS File. This example returns information about spreadsheet file
Exporting to the File
xlswrite function to export a matrix to an Excel spreadsheet file. With
xlswrite, you can export data from the workspace to any worksheet in the file, and to any location within that worksheet.
Example -- Writing To an XLS File. This example writes a mix of text and numeric data to the file
xlswrite, specifying a worksheet labeled
Temperatures, and the region within the worksheet to write the data to. The 4-by-2 matrix is written to the rectangular region that starts at cell
E1 in its upper-left corner:
Adding a New Worksheet. If the worksheet being written to does not already exist in the file, MATLAB displays the following warning:
You can disable these warnings with the command
Importing from the File
xlsread to import a matrix from an Excel spreadsheet file into the MATLAB workspace. You can import data from any worksheet in the file, and from any location within that worksheet. You can also optionally have
xlsread open an Excel window showing the file and then interactively select the worksheet and range of data to be read by the function.
Three separate outputs from
Example -- Reading from an XLS File. Continuing with the previous example, to import only the numeric data, use
xlsread with a single return argument.
xlsread ignores any leading row or column of text in the numeric result:
To import both numeric data and text data, specify two return values for
|Exporting Audio/Video Data||Lotus 123 Spreadsheets|
© 1994-2005 The MathWorks, Inc.