资源简介
这个Matlab程序,可以读取任何文本文件,并返回一个内容的数组。它在执行过程中,对每个字符串进行匹配,每行作为一次匹配的结束。

代码片段和文件信息
function [data result]= readtext(text delimiter comment quotes options)
% Usage: [data result]= readtext(source delimiter comment quotes options)
%
% Whatever text (file) you give it readtext returns an array of the contents (or send me a
% bug report). Matlab can‘t read variable length lines or variable type values with the standard
% library. readtext can read any text file. Any string (or even regexp) can be delimiting
% default is a comma. Everything after (and including) a comment character until the line end
% is ignored. Quote characters may also be given everything between them is treated as one item.
% There are options to control what will be converted to numbers and how empty items are saved.
%
% If you find any errors please let me know: peder at axensten dot se.
%
% source: the file to be read. May be a file path or just the file name.
% OR: The text itself see ‘textsource‘ below.
%
% delimiter: (default: ‘‘) any non-empty string. May be a regexp but this is slow on large files.
%
% comment: (default: ‘‘) zero or one character. Anything after (and including) this character
% until the end of the line will be ignored.
%
% quotes: (default: ‘‘) zero one (opening quote equals closing) or two characters (opening
% and closing quote) to be treated as paired braces. Everything between the quotes will be
% treated as one item. The quotes will remain. Quotes may be nested.
%
% options: (default: ‘‘) may contain (concatenate combined options):
% - ‘textsource‘: source contains the actual text to be processed not the file name.
% - ‘textual‘: no numeric conversion (‘data‘ is a cell array of strings only)
% - ‘numeric‘: everything is converted to a number or NaN (‘data‘ is a numeric array empty items
% are converted to NaNs unless ‘empty2zero‘ is given)
% - ‘empty2zero‘: an empty field is saved as zero and
% - ‘empty2NaN‘: an empty field is saved as NaN.
% - ‘usewaitbar‘: call waitbar to report progress. If you find the wait bar annoying get ‘waitbar
% alternative‘ at http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11398
%
% data: A cell array containing the read text divided into cells by delimiter and line
% endings. ‘data‘ will be empty if the file is not found could not be opened or is empty.
% With the option ‘numeric‘ ‘data‘ will be a numeric array with ‘textual‘ ‘data‘ will be a
% cell array of strings only and otherwise it will be a mixed cell array. For Matlab < version 7
% returned strings may contain leading white-space.
%
% result: a structure:
% .min: minimum number of columns found in a line.
% .max: number of columns in ‘data‘ before removing empty columns.
% .rows: number of rows in ‘data‘ before removing empty rows.
% .numberMask: true if numeric conversion (‘NaN‘ converted to NaN counts).
% .number: number of nume
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 102 2008-06-21 12:52 loadFile.do_files\00th.png
文件 96 2008-06-21 12:52 loadFile.do_files\90th.png
文件 646 2008-06-21 12:52 loadFile.do_files\blue_band_536x5.gif
文件 57 2008-06-21 12:52 loadFile.do_files\bullet.gif
文件 6693 2008-06-21 12:52 loadFile.do_files\Captcha.htm
文件 10462 2008-06-21 12:52 loadFile.do_files\cmnty1.css
文件 70 2008-06-21 12:52 loadFile.do_files\doc.gif
文件 97 2008-06-21 12:52 loadFile.do_files\dots_rnav.gif
文件 152 2008-06-21 12:52 loadFile.do_files\dots_rnav_top.gif
文件 64 2008-06-21 12:52 loadFile.do_files\exclamation.gif
文件 145 2008-06-21 12:52 loadFile.do_files\fullstar.gif
文件 145 2008-06-21 12:52 loadFile.do_files\fullstar_grey.gif
文件 140 2008-06-21 12:52 loadFile.do_files\halfstar.gif
文件 117 2008-06-21 12:52 loadFile.do_files\ltblue_top_nav_trans.gif
文件 155 2008-06-21 12:52 loadFile.do_files\mail_brdr.gif
文件 2569 2008-06-21 12:52 loadFile.do_files\mlc_logo.gif
文件 64 2008-06-21 12:52 loadFile.do_files\question.gif
文件 43 2008-06-21 12:52 loadFile.do_files\s99813412818231.gif
文件 3379 2008-06-21 12:52 loadFile.do_files\site3.css
文件 43 2008-06-21 12:52 loadFile.do_files\spacer.gif
文件 66 2008-06-21 12:52 loadFile.do_files\submitfile.gif
文件 39399 2008-06-21 12:52 loadFile.do_files\s_code.js
文件 260 2008-06-21 12:52 loadFile.do_files\xm
目录 0 2008-06-21 12:52 loadFile.do_files
文件 51796 2008-06-21 12:52 loadFile.do.htm
文件 20055 2008-06-21 12:52 readtext.m
----------- --------- ---------- ----- ----
136815 26
- 上一篇:LS信道估计算法仿真代码
- 下一篇:基于multisim的555多谐振荡器
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论