ImageVerifierCode 换一换
格式:DOC , 页数:7 ,大小:53KB ,
资源ID:4705662      下载积分:5 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/4705662.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(关于matlab读取excel以及处理.doc)为本站上传会员【二***】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

关于matlab读取excel以及处理.doc

1、 在许多时候我们要借助于matlab读取excel的内容进行处理,一下是一种常用的处理方法       office的表格文件也就是xls文件本质上就是一个二维矩阵,二维矩阵是用来保存数据的最佳方式,所以在日常工作中,我们从其它地方获取的数据通常都被保存为xls格式,但处理数据时,我们却需要把xls文件的数据导入到matlab里进行处理。       如果你只处理一个文件并且只做一次的话,你可以手动来拷贝粘贴,这花费不了你太多时间。如果有很多xls文件,或者你的xls文件的内容可能随时被修改,那么下面的方法可以派上用场。       matlab自身提供了大量的函数,包括读取o

2、ffice文件。其中xlsread和xlswrite就是专门用来读取xls文件里的数据的。这两个函数的使用方法可以直接查看matlab自带的帮助。       xlsread对于纯数据的xls文件支持很完美,也就是说当xls文件里的每个格子都是“数”时,xlsread会直接返回一个实数矩阵。但是通 常我们拿到xls文件并不是这样,它的表头多半是描述性文字,它的数据也有可能是文字,有些位置的数据还有可能是缺失的。xlsread对这样的文件读取 无能为力,或者说需要大量的时间去协调数据的位置信息。要是有一个函数,能够按照原有的顺序直接读取所有的单位格数据就好了。当然,这时候返回的矩阵就不 能是

3、一个数值矩阵了,它将会是一个cell矩阵,里面的每个元素类型可能不一样。        matlab本身并不提供这个功能,但是另外有一个函数officedoc完美的实现这个功能。这个函数包可以去OfficeDoc官方网站上去下载,解压缩后放到工作路径上即可。使用方法可以查询help officedoc。officedoc是收费函数包,但有免费版本,而且其免费版本可以实现上面我们所说的效果(收费版本主要是可以用来修改office文件)。       例子:       在matlab中读取xls格式的文件内容如应用如下函数:       1.bb=xlsread('c:featu

4、re.xls','a0:an40'),其中:c:feature.xls为文件存放的地址,a0:a40为将要读取的单元格的范围.bb为读取的矩阵在MATLAB中的变量名.       2.使用m文件脚本如下:           Excel = actxserver('Excel.Application');          set(Excel, 'Visible', 1);          Workbooks = Excel.Workbooks;          Workbook = invoke(Workbooks, 'Open', [cd,'\feature\AB

5、C.xls']); %%  读取 ABC.xls:sheet1  a1(即 R1C1)~an40(即 R240c40) 范围内的 40by40 矩阵         read_excel=ddeinit('excel','ABC.xls:sheet1');         feature1 = ddereq(read_excel, 'R1c1:R40c40');         feature1 %%  关闭ABC.xls         invoke(Excel, 'Quit');         delete(Excel);           注意:在

6、使用时将m文件与xls文件存于同一个目录下.另外:sheet1:可以重命名,且读取sheet的名称要和实际存放的名称相同. matlab读取excel,txt文件函数 注意matlab不识别中文,读写的文件中最好不含有中文 excel读取函数 xlsread text  读取函数csvread XLSREAD Get data and text from a spreadsheet in an Excel workbook.     [NUMERIC,TXT,RAW]=XLSREAD(FILE) reads the data specified in the Excel

7、    file, 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.        [NUMERIC,TXT,RAW]=XLSREAD(FILE,SHEET,RANGE) reads the data specified     in RANGE from the worksheet SHEET

8、 in the Excel file specified in FILE.     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,R

9、ANGE,'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 available as a COM server.      In this mode, XLSREAD does not use Excel as a COM server, which limits     import ability. Without Excel as a

10、 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.       [NUMERIC,TXT,RAW]=XLSREAD(FILE,SHEET,RANGE,'',CUSTOMFUN)     [NUMERIC,TXT,RAW,CUSTOMOUTPUT]=XLSREAD(FILE,SH

11、EET,RANGE,'',CUSTOMFUN)     When the Excel COM server is used, allows passing in a handle to a     custom function.  This function will be called just before retrieving     the actual data from Excel. It must take an Excel Range object (e.g. of     type 'Interface.Microsoft_Excel_5.0_Object_Lib

12、rary.Range') as input,     and return one as output.  Optionally, this custom function may return     a second output argument, which will be returned from XLSREAD as the     fourth output argument, CUSTOMOUTPUT.  For details of what is possible     using the EXCEL COM interface, please refer t

13、o Microsoft documentation.       INPUT PARAMETERS:     FILE: string defining the file to read from. Default directory is pwd.           Default extension is 'xls'.     SHEET: string defining worksheet name in workbook FILE.            double scalar defining worksheet index in workbook FILE. Se

14、e            NOTE 1.     RANGE: string defining the data range in a worksheet. See NOTE 2.     MODE: string enforcing basic import mode. Valid value = 'basic'.  This     is the mode always used when COM is not available (e.g. on Unix).       RETURN PARAMETERS:     NUMERIC = n x m array of typ

15、e 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]=x

16、lsread(FILE);        [NUMERIC,TXT,RAW]=xlsread(FILE);       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

17、')       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 fro

18、m 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:        NU

19、MERIC = 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. Click OK in the Data        Selection Dialog when you have finished selecting the active region.       9. Using the custom

20、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';     

21、         This will convert to dates all cells where that is possible.       NOTE 1: 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 pro

22、mpt           you to click the OK button in that dialogue to continue in MATLAB.            (Only supported when Excel COM server is available.)     NOTE 2: The regular form is: 'D2:F3' to select rectangular region D2:F3           in a worksheet. RANGE is not case sensitive and uses Excel A1

23、           notation (see Excel Help). (Only supported when Excel COM server           is available.)     NOTE 3: Excel formats other than the default can also be read.            (Only supported when Excel COM server is available.)       See also xlswrite, csvread, csvwrite, dlmread, dlmwrite

24、 textscan.     Reference page in Help browser        doc xlsread   CSVREAD Read a comma separated value file.     M = CSVREAD('FILENAME') reads a comma separated value formatted file     FILENAME.  The result is returned in M.  The file can only contain     numeric values.       M = CSVR

25、EAD('FILENAME',R,C) reads data from the comma separated value     formatted file starting at row R and column C.  R and C are zero-     based so that R=0 and C=0 specifies the first value in the file.       M = CSVREAD('FILENAME',R,C,RNG) reads only the range specified     by RNG = [R1 C1 R2 C2

26、] where (R1,C1) is the upper-left corner of     the data to be read and (R2,C2) is the lower-right corner.  RNG     can also be specified using spreadsheet notation as in RNG = 'A1..B7'.       CSVREAD fills empty delimited fields with zero.  Data files where     the lines end with a comma will

27、produce a result with an extra last     column filled with zeros.       See also csvwrite, dlmread, dlmwrite, load, fileformats, textscan.     Reference page in Help browser        doc csvread Matlab如何读取Excel 表格数据 Subject: Are there any examples that show how to use the ActiveX

28、automation interface to connect MATLAB to Excel? Problem Description I am trying to control Excel from MATLAB using ActiveX. Are there any examples that show how to use the ActiveX automation interface from Excel to do this? Solution: Most of the functionality that you get from ActiveX i

29、s dependent on the object model, which the external application implements. Consequently, we are usually unable tp provide much information about the functions that you need to use in the remote application to perform a particular function. We do, however, have an example that shows how to do perfor

30、m common functions in Excel. We also recommend that you become more familiar with the Excel object model in order to better use Excel's ActiveX automation interface from MATLAB. You can find more information on this interface by selecting the "Microsoft Excel Visual Basic Reference" topic in the

31、 Microsoft Excel Help Topic dialog. This topic area contains a searchable description of Excel methods and properties. The following example demonstrates how to insert MATLAB data into Excel. It also shows how to extract some data from Excel into MATLAB. For more information, refer to the indivi

32、dual comments for each code segment. % Open Excel, add workbook, change active worksheet, % get/put array, save, and close % First open an Excel Server Excel = actxserver('Excel.Application'); set(Excel, 'Visible', 1); % Insert a new workbook Workbooks = Excel.Workbooks; Workbo

33、ok = invoke(Workbooks, 'Add'); % Make the second sheet active Sheets = Excel.ActiveWorkBook.Sheets; sheet2 = get(Sheets, 'Item', 2); invoke(sheet2, 'Activate'); % Get a handle to the active sheet Activesheet = Excel.Activesheet; % Put a MATLAB array into Excel A = [1 2; 3 4];

34、 ActivesheetRange = get(Activesheet,'Range','A1:B2'); set(ActivesheetRange, 'Value', A); % Get back a range. It will be a cell array, % since the cell range can % contain different types of data. Range = get(Activesheet, 'Range', 'A1:B2'); B = Range.value; % Convert to a double mat

35、rix. The cell array must contain only scalars. B = reshape([B{:}], size(B)); % Now save the workbook invoke(Workbook, 'SaveAs', 'myfile.xls'); % To avoid saving the workbook and being prompted to do so, % uncomment the following code. % Workbook.Saved = 1; % invoke(Workbook, 'Close

36、'); % Quit Excel invoke(Excel, 'Quit'); % End process delete(Excel); There are several options for connecting MATLAB with Excel. For an example that shows how to connect MATLAB with Excel using Excel Link, please refer to the following URL: For an example that shows how to c

37、onnect MATLAB with Excel using DDE, please refer to the following URL: For information on how to use the XLSREAD function to read .xls files, please refer to the following URL: 在Matlab GUI中读取数据或其它文件 假设在GUI(in Matlab)中设计好一按钮,点击以后弹出对话框,并希望获取来自电脑上任一文件夹下的数据或其它文件。 做法:假设要读取在桌面上一名叫ATR_

38、ALL.dat的数据文件,并将其值赋到Data变量,其程序代码为: [filename, pathname] = uigetfile; if (filename==0 & pathname==0)     msgbox('您没有选择文件,请重新选择!','打开文件出错','error'); else     NumericalDatum=load([pathname, filename]);     % NumericalDatum=xlsread([pathname, filename]); % 然后把从计算机其它文件夹读取的数据文件保存到当前文件夹     save NumericalDatum.dat NumericalDatum -ascii; % xlswrite('NumericalDatum.xls',NumericalDatum);     msgbox('打开及读取数据完毕!','确认','warn'); end ...... 在新的应用文件中 % 最后再从当前文件夹将数据读取出来,用于当前程序 load NumericalDatum.dat; % NumericalDatum=xlsread('NumericalDatum.xls');

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服