资源简介
这个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多谐振荡器
相关资源
- LS信道估计算法仿真代码
- 基于HMM的语音识别系统的matlab仿真
- Matlab与蒙特卡洛仿真
- SAR点目标仿真
- matlab 实现粒子群优化算法代码
- 史密斯圆图 matlab实现
- 一维信号的Haar小波分解与重构matlab程
- 潮流计算matlab代码
- Kohonen神经网络算法的matlab实现
- 基于matlab的电力系统仿真
- 自适应最陡下降法Matlab仿真
- MATLAB AGC
- 图像处理 人脸识别皮肤提取 经典ma
- 蚁群-微分进化算法解TSP
- 蚁群聚类算法matlab实现
- matlab三维散乱点云曲率算法
- 现代控制系统matlab程序
- 图像分割与腐蚀膨胀matlab代码
- AM调制解调matlab实验代码加噪声
- 元胞自动机交通流模型代码matlab代码
- Buck-Boost充电Matlab仿真模型
- 霍夫圆边缘检测MATLAB
- matlab BP神经网络 0-9数字识别
- matlab椒盐高斯混合噪声滤波
- 背景差分 matlab 代码
- 最小二乘椭圆拟合matlab
- matlab 螺旋波模拟程序,基于FHN模型
- 清扫机器人路径规划算法仿真
- 基于MATLAB中级联分类器的人脸五官分
- 基于人工神经网络的信号预测在Matl
评论
共有 条评论