楼主: xuning5176
1684 0

[学习分享] Matlab 导入EXCEL数据 [推广有奖]

  • 11关注
  • 9粉丝

已卖:779份资源

讲师

87%

还不是VIP/贵宾

-

威望
0
论坛币
3812 个
通用积分
15.5361
学术水平
5 点
热心指数
3 点
信用等级
2 点
经验
4031 点
帖子
212
精华
0
在线时间
802 小时
注册时间
2009-10-13
最后登录
2025-5-28

楼主
xuning5176 发表于 2013-3-26 16:33:51 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
在Matlab命令窗口中使用xlsread函数   
注意啦:在较低版本的Matlab无法识别xlsx文件(即EXCEL2007文件),可以将其转换为XLS文件后在使用Matlab打开

  XLSREAD Get data and text from a spreadsheet in an Excel workbook.
    [NUMERIC,TXT,RAW]=XLSREAD(FILE,SHEET,RANGE) reads the data specified
    in RANGE from the worksheet SHEET, in the Excel file specified in FILE. The
    numeric cells in FILE are returned in NUMERIC, the text cells in FILE are
    returned in TXT, while the raw, unprocessed cell content is returned in
    RAW. It is possible to select the range of data interactively (see Examples
    below). Please note that the full functionality of XLSREAD depends on the
    ability to start Excel as a COM server from MATLAB.

    [NUMERIC,TXT,RAW]=XLSREAD(FILE,SHEET,RANGE,'basic') reads an XLS file as
    above, using basic input mode. This is the mode used on UNIX platforms
    as well as on Windows when Excel is not availabe as a COM server.  
    In this mode, XLSREAD does not use Excel as a COM server, which limits
    import ability. Without Excel as a COM server, RANGE will be ignored
    and, consequently, the whole active range of a sheet will be imported.
    Also, in basic mode, SHEET is case-sensitive and must be a string.

    INPUT PARAMETERS:
    FILE: string defining the file to read from. Default directory is pwd.
          Default extension is 'xls'. See NOTE 1.
    SHEET: string defining worksheet name in workbook FILE.
           double scalar defining worksheet index in workbook FILE.
    RANGE: string defining the data range in a worksheet. See NOTE 2.
    MODE: string enforcing basic import mode. Valid value = 'basic'.

    RETURN PARAMETERS:
    NUMERIC = n x m array of type double.
    TXT = r x s cell string array containing text cells in RANGE.
    RAW = v x w cell array containing unprocessed numeric and text data.
    Both NUMERIC and TXT are subsets of RAW.

    EXAMPLES:
    1. Default operation:  
       NUMERIC = xlsread(FILE);
       [NUMERIC,TXT]=xlsread(FILE);
       [NUMERIC,TXT,RAW]=xlsread(FILE);

    2. Get data from the 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')
  
    7. Get data from a specified region in a named sheet:
       NUMERIC = xlsread('c:\matlab\work\myspreadsheet','NBData','a2:j5')
  
    8. Get data from a region in a sheet specified by index:
       NUMERIC = xlsread('c:\matlab\work\myspreadsheet',2,'a2:j5')
  
    9. 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.

    NOTE 1: If FILE is the empty string or omitted, an error is thrown.
    NOTE 2: The first worksheet of the workbook is the default sheet. If SHEET
            is -1, Excel comes to the foreground to enable interactive selection
           (optional). In interactive mode, a dialogue will prompt you to click
           the OK button in that dialogue to continue in MATLAB.
    NOTE 3: The regular form is: 'D2:F3' to select rectangular region D2:F3 in a
           worksheet. RANGE is not case sensitive and uses Excel A1 notation.
           (see Excel Help).

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:excel数据 MATLAB EXCEL matla atlab EXCEL matlab

金融爱好者。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 20:48