2. Get data from the default region: NUMERIC = xlsread('c:\matlab\work\myspreadsheet')
3. Get data from the used area in a sheet other than the first sheet: NUMERIC = xlsread('c:\matlab\work\myspreadsheet','sheet2')
4. Get data from a named sheet: NUMERIC = xlsread('c:\matlab\work\myspreadsheet','NBData')
5. Get data from a specified region in a sheet other than the first sheet: NUMERIC = xlsread('c:\matlab\work\myspreadsheet','sheet2','a2:j5')
6. Get data from a specified region in a named sheet: NUMERIC = xlsread('c:\matlab\work\myspreadsheet','NBData','a2:j5')
7. Get data from a region in a sheet specified by index: NUMERIC = xlsread('c:\matlab\work\myspreadsheet',2,'a2:j5')
8. Interactive region selection: NUMERIC = xlsread('c:\matlab\work\myspreadsheet',-1); You have to select the active region and the active sheet in the EXCEL window that will come into focus. Enter any letter at Matlab command line when finish selecting the active region.
9. Using the custom function: [NUMERIC,TXT,RAW,CUSTOMOUTPUT] = xlsread('equity.xls', ..., @MyCustomFun) Where the CustomFun is defined as:
function [DataRange, customOutput] = MyCustomFun(DataRange) DataRange.NumberFormat = 'Date'; customOutput = 'Anything I want';
或者下面例子的方法:
Example -- Importing Data From an Excel Application
Assume that you have an Excel spreadsheet stocks.xls. This spreadsheet contains the prices of three stocks in row 3 (columns 1 through 3) and the number of shares of these stocks in rows 6 through 8 (column 2). Initiate conversation with Excel with the command channel = ddeinit('excel','stocks.xls')
DDE functions require the rxcy reference style for Excel worksheets. In Excel terminology the prices are in r3c1:r3c3 and the shares in r6c2:r8c2. Request the prices from Excel:
prices = ddereq(channel,'r3c1:r3c3')
prices = 42.50 15.00 78.88
Next, request the number of shares of each stock: shares = ddereq(channel, 'r6c2:r8c2')