



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
matlab与excel xlsread、xlswrite实用方法num, txt, raw, X =xlsread(filename, sheet, range)filename, sheet, range 文件名,sheet名、范围num, txt, raw, X 输出excel数据写入函数:status, message =xlswrite(filename, M, sheet, range)filename, M, sheet, range 文件名,数据、sheet名、范围ExamplesExample 1 Reading Numeric DataThe Microsoft Excel spreadsheet filetestdata1.xlscontains this data: 1 6 2 7 3 8 4 9 5 10To read this data into MATLAB, use this command:A = xlsread(testdata1.xls)A = 1 6 2 7 3 8 4 9 5 10Example 2 Handling Text DataThe Microsoft Excel spreadsheet filetestdata2.xlscontains a mix of numeric and text data: 1 6 2 7 3 8 4 9 5 textxlsreadputs aNaNin place of the text data in the result:A = xlsread(testdata2.xls)A = 1 6 2 7 3 8 4 9 5 NaNExample 3 Selecting a Range of DataTo import only rows4and5from worksheet1, specify the range asA4:B5:A = xlsread(testdata2.xls, 1, A4:B5)A = 4 9 5 NaNExample 4 Handling Files with Row or Column HeadersA Microsoft Excel spreadsheet labeledTemperaturesin filetempdata.xlscontains two columns of numeric data with text headers for each column:Time Temp12 9813 9914 97If you want to import only the numeric data, usexlsreadwith a single return argument. Specify the filename and sheet name as inputs.xlsreadignores any leading row or column of text in the numeric result.ndata = xlsread(tempdata.xls, Temperatures)ndata = 12 98 13 99 14 97To import both the numeric data and the text data, specify two return values forxlsread:ndata, headertext = xlsread(tempdata.xls, Temperatures)ndata = 12 98 13 99 14 97headertext = Time Temp+ExamplesExample 1 Writing Numeric Data to the Default WorksheetWrite a 7-element vector to Microsoft Excel file testdata.xls. By default, xlswrite writes the data to cells A1 through G1 in the first worksheet in the file:xlswrite(testdata.xls, 12.7 5.02 -98 63.9 0 -.2 56)Example 2 Writing Mixed Data to a Specific WorksheetThis example writes the following mixed text and numeric data to the filetempdata.xls:d = Time, Temp; 12 98; 13 99; 14 97;Callxlswrite, specifying the worksheet labeledTemperatures, and the region within the worksheet to write the data to.xlswritewrites the 4-by-2 matrix to the rectangular region that starts at cellE1in its upper left corner:s = xlswrite(tempdata.xls, d, Temperatures, E1)s = 1The output statussshows that the write operation succeeded. The data appears as shown here in the output file:Time Temp 12 98 13 99 14 97Example 3 Appending a New Worksheet to the FileNow write the same data to a worksheet that doesnt yet exist intempdata.xls. In this case,xlswriteappends a new sheet to the workbook, calling it by the name you supplied in thesheetsinput argument,NewTemp.xlswritedisplays a warning indicating that it has added a new worksheet to the file:xlswrite(tempdata.xls, d, NewTemp, E1)Warning: Added specified worksheet.If you dont want to see these warnings, you can turn them off with this command:warning off MATLAB:xlswrite:AddSheetNow try the write command again, this time creating another new worksheet,NewTemp2. Although the message does not appear this time, you can still retrieve it and its identifier from
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医用气体扩建项目建议书
- 人力资源基础管理
- 2025年乡镇应急管理工作招聘考试面试技巧与模拟题集
- 2025年山东省济宁市中考生物试卷附答案
- 预算管理一体化下预算绩效管理机制的优化
- 2025-2030中国ABF载板市场深度调研及未来销售模式预测报告
- 2025年甘肃省行政执法证考试题库附答案
- 2025年甘肃省甘南藏族自治州辅警考试题库(附答案)
- 销售团队激励工具包
- 廉洁行医教学课件
- 2025年质量月全面质量管理知识竞赛题库及答案
- 北京市东城区2024-2025学年高一下学期期末语文试题(含答案)
- 2025年司法考试刑法案例分析实战演练试卷(附司法解释案例解析)含答案
- 全员安全生产责任制考核制度和考核标准
- 山东吕剧教学课件
- 2025年养老护理员考试试卷及答案
- 2025年宜宾市中考语文试题卷(含答案详解)
- 新能源装备制造业行业研究报告
- 家博会现场抽奖活动方案
- 古建筑保护和修复工程项目可行性研究报告
- 第1章 勾股定理 问题解决策略 课件 北师大版数学八年级上册
评论
0/150
提交评论