版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、MATLAB的数据导入与导出,MATLAB的数据导入,数据的直接输入 A=1 2 3 4 5 6; M文件中生成 利用fopen,fread,和MATLAB输入输出函数。 从ASCII文件中导入 利用load命令,LOAD 接受绝对或相对路径输入。如果文件的扩展名不是.mat,则系统把文件当作ASCII码文件进行处理。 单独使用时,默认输入的命令matlab.mat。如果找不到这个文件,则会报错。 LOAD FILENAME X loads only X. LOAD FILENAME X Y Z . loads just the specified variables. The wildcar
2、d * loads variables that match a pattern (MAT-file only). 如果文件是mat文件,所需变量将在工作空间产生,否则,会产生一个双精度矩阵,矩阵名为文件名。 S = LOAD(.) returns the contents of FILENAME in variable S. If FILENAME is a MAT file, S is a struct containing fields matching the variables retrieved. If FILENAME is an ASCII file, S is a doubl
3、e precision array.,举例,load fname a* % Load variables starting with a load fname -regexp bd3$ % Load variables starting with b and % followed by 3 digits load fname -regexp d % Load variables containing any digits,利用特定文件读取函数 dlmread wk1read textscan textread 创建mex文件读取文件 创建其他程序文件读取,MATLAB的数据导出,diary s
4、ave ascii 以特定格式写入文件 利用特定文件写入程序 dlmwrite 作为mat文件输出数据,MATLAB的文件操作,UIGETFILE 对话框打开文件方式. FILENAME, PATHNAME, FILTERINDEX = UIGETFILE(FILTERSPEC, TITLE) 显示一个需要用户完成的对话框,返回文件名,文件路径,和是否打开成功,如果打开成功,返回成功标志,否则会出现一错误信息,用户可以打开另一文件,或取消。 filename, pathname, filterindex = uigetfile(*.m, Pick an M-file);,MATLAB的文件操作
5、,UIPUTFILE 对话框打开文件方式. FILENAME, PATHNAME, FILTERINDEX = UIPUTFILE(FILTERSPEC, TITLE) 显示一个需要用户完成的对话框,返回文件名,文件路径,和是否打开成功,如果打开成功,返回成功标志,否则会出现一错误信息,用户可以打开另一文件,或取消。 filename, pathname = uiputfile(matlab.mat, Save Workspace as);,MATLAB的文件操作,FOPEN 打开文件 FILENAME 可以是一个相对路径,如果文件不在当前目录,系统将会在其他路径进行搜索。 FID = FOP
6、EN(FILENAME,PERMISSION) FID 称为文件标识符,如果错误,返回-1,MATLAB的文件操作,r read w write (create if necessary) a append (create if necessary) r+ read and write (do not create) w+ truncate or create for read and write a+ read and append (create if necessary) W write without automatic flushing A append without automa
7、tic flushing,MATLAB的文件操作,Two file identifiers are automatically available and need not be opened. They are FID=1 (standard output) and FID=2 (standard error). FID, MESSAGE = FOPEN(FILENAME,PERMISSION) returns a system dependent error message if the open is not successful.,MATLAB的文件操作,FCLOSE Close fi
8、le. ST = FCLOSE(FID) closes the file with file identifier FID, which is an integer obtained from an earlier FOPEN. FCLOSE returns 0 if successful and -1 if not. ST = FCLOSE(a) closes all open files, except 0, 1 and 2.,MATLAB的文件操作,FGETS Read line from file, keep newline character. TLINE = FGETS(FID)
9、returns the next line of a file associated with file identifier FID as a MATLAB string. The line terminator is included. Use FGETL to get the next line WITHOUT the line terminator. If just an end-of-file is encountered then -1 is returned.,MATLAB的文件操作,FPRINTF Write formatted data to file. COUNT = FP
10、RINTF(FID,FORMAT,A,.) formats the data in the real part of array A (and in any additional array arguments), under control of the specified FORMAT string, and writes it to the file associated with file identifier FID. COUNT is the number of bytes successfully written. FID is an integer file identifier obtained from FOPEN. It can also be 1 for standard output (the screen) or 2 for standard error. If FID is omitted
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年旌德县幼儿园教师招教考试备考题库及答案解析(必刷)
- 2024年燕山大学马克思主义基本原理概论期末考试题带答案解析
- 2025年河北工业职业技术大学马克思主义基本原理概论期末考试模拟题带答案解析(必刷)
- 2024年隆昌县幼儿园教师招教考试备考题库附答案解析(必刷)
- 2025年昆明医科大学海源学院马克思主义基本原理概论期末考试模拟题带答案解析(夺冠)
- 2025年吉林动画学院马克思主义基本原理概论期末考试模拟题带答案解析(必刷)
- 2026年洛阳科技职业学院单招综合素质考试题库带答案解析
- 2025年汤阴县招教考试备考题库附答案解析(夺冠)
- 2025年南宁师范大学马克思主义基本原理概论期末考试模拟题附答案解析(夺冠)
- 2025年阳高县幼儿园教师招教考试备考题库附答案解析
- 2026年安全生产开工第一课筑牢复工复产安全防线
- 2026年标准版离婚协议书(无财产)
- 山西大学附属中学2025-2026学年高三1月月考生物(含答案)
- 2024年货车驾驶员管理制度
- T/GIEHA 035-2022医院室内空气质量要求
- 2025年上海市长宁区初三二模语文试卷(含答案)
- 五年级上册数学计算题每日一练(共20天带答案)
- CQI-23Molding Process Assessment 模塑系统评估审核表-中英文(空)
- 新生儿消化不良的健康宣教护理课件
- 2025年事业单位考试(自然科学专技类C类)综合应用能力试卷与参考答案
- 2024年北京版小学英语必背单词表
评论
0/150
提交评论