- 浏览: 4333616 次
- 性别:
- 来自: 湛江
博客专栏
-
SQLite源码剖析
浏览量:79428
-
WIN32汇编语言学习应用...
浏览量:68376
-
神奇的perl
浏览量:101498
-
lucene等搜索引擎解析...
浏览量:281206
-
深入lucene3.5源码...
浏览量:14608
-
VB.NET并行与分布式编...
浏览量:65559
-
silverlight 5...
浏览量:31320
-
算法下午茶系列
浏览量:45206
文章分类
最新评论
-
yoyo837:
counters15 写道目前只支持IE吗?插件的东西是跨浏览 ...
Silverlight 5 轻松开启绚丽的网页3D世界 -
shuiyunbing:
直接在前台导出方式:excel中的单元格样式怎么处理,比如某行 ...
Flex导出Excel -
di1984HIT:
写的很好~
lucene入门-索引网页 -
rjguanwen:
在win7 64位操作系统下,pygtk的Entry无法输入怎 ...
pygtk-entry -
ldl_xz:
http://www.9958.pw/post/php_exc ...
PHPExcel常用方法汇总(转载)
text1.txt内容如下:
货币资金,6865234.00 , 短期借款,120000.00
应收票据,72120.00 , 应付票据,85500.00
应收账款,38050.00 , 应付账款,80200.00
减:坏账准备,, 预收账款,
应收账款净额,38050.00 , 应付工资,
其他应收款,, 应付福利费,8430.00
预付账款,26600.00 , 应交税金,24420.00
存 货,281950.00 , 应付股利,34000.00
待摊费用,100.00 , 其他应付款,
流动资产合计,7284054.00 , 预提费用,1600.00
>> help textread
TEXTREAD Read formatted data from text file.
A = TEXTREAD('FILENAME')
A = TEXTREAD('FILENAME','',N)
A = TEXTREAD('FILENAME','',param,value, ...)
A = TEXTREAD('FILENAME','',N,param,value, ...) reads numeric data from
the file FILENAME into a single variable. If the file contains any
text data, an error is produced.
[A,B,C, ...] = TEXTREAD('FILENAME','FORMAT')
[A,B,C, ...] = TEXTREAD('FILENAME','FORMAT',N)
[A,B,C, ...] = TEXTREAD('FILENAME','FORMAT',param,value, ...)
[A,B,C, ...] = TEXTREAD('FILENAME','FORMAT',N,param,value, ...) reads
data from the file FILENAME into the variables A,B,C,etc. The type of
each return argument is given by the FORMAT string. The number of
return arguments must match the number of conversion specifiers in the
FORMAT string. If there are fewer fields in the file than in the
format string, an error is produced. See FORMAT STRINGS below for
more information.
If N is specified, the format string is reused N times. If N is -1 (or
not specified) TEXTREAD reads the entire file.
If param,value pairs are supplied, user configurable options customize
the behavior of TEXTREAD. See USER CONFIGURABLE OPTIONS below.
TEXTREAD works by matching and converting groups of characters from the
file. An input field is defined as a string of non-whitespace
characters extending to the next whitespace or delimiter character
or until the field width is exhausted. Repeated delimiter characters
are significant while repeated whitespace characters are treated as
one.
FORMAT STRINGS
If the FORMAT string is empty, TEXTREAD will only numeric data.
The FORMAT string can contain whitespace characters (which are
ignored), ordinary characters (which are expected to match the next
non-whitespace character in the input), or conversion specifications.
Supported conversion specifications:
%n - read a number - float or integer (returns double array)
%5n reads up to 5 digits or until next delimiter
%d - read a signed integer value (returns double array)
%5d reads up to 5 digits or until next delimiter
%u - read an integer value (returns double array)
%5u reads up to 5 digits or until next delimiter
%f - read a floating point value (returns double array)
%5f reads up to 5 digits or until next delimiter
%s - read a whitespace separated string (returns cellstr)
%5s reads up to 5 characters or until whitespace
%q - read a double-quoted string, ignoring the quotes (returns cellstr)
%5q reads up to 5 non-quote characters or until whitespace
%c - read character or whitespace (returns char array)
%5c reads up to 5 characters including whitespace
%[...] - reads characters matching characters between the
brackets until first non-matching character or
whitespace (returns cellstr)
use %[]...] to include ]
%5[...] reads up to 5 characters
%[^...] - reads characters not matching characters between the
brackets until first matching character or whitespace
(returns cellstr)
use %[^]...] to exclude ]
%5[^...] reads up to 5 characters
Note: Format strings are interpreted as with sprintf before parsing.
For example, textread('mydata.dat','%s\t') will search for a tab not
the character '\' followed by the character 't'. See the Language
Reference Guide or a C manual for complete details.
Using %* instead of % in a conversion causes TEXTREAD to skip the
matching characters in the input (and no output is created for this
conversion).
The % can be followed by an optional field width to handle fixed
width fields. For example %5d reads a 5 digit integer. In
addition the %f format supports the form %<width>.<prec>f.
USER CONFIGURABLE OPTIONS
Possible param/value options are:
'bufsize' - maximum string length in bytes (default is 4095)
'commentstyle' - one of
'matlab' -- characters after % are ignored
'shell' -- characters after # are ignored
'c' -- characters between /* and */ are ignored
'c++' -- characters after // are ignored
'delimiter' - delimiter characters (default is none)
'emptyvalue' - empty cell value in delimited files (default is 0)
'endofline' - end of line character (default determined from file)
'expchars' - exponent characters (default is 'eEdD')
'headerlines' - number of lines at beginning of file to skip
'whitespace' - whitespace characters (default is ' \b\t')
TEXTREAD is useful for reading text files with a known format. Both
fixed and free format files can be handled.
Examples:
Suppose the text file mydata.dat contains data in the following form:
Sally Type1 12.34 45 Yes
Joe Type2 23.54 60 No
Bill Type1 34.90 12 No
Read each column into a variable
[names,types,x,y,answer] = textread('mydata.dat','%s%s%f%d%s');
Read first column into a cell array (skipping rest of line)
[names]=textread('mydata.dat','%s%*[^\n]')
Read first character into char array (skipping rest of line)
[initials]=textread('mydata.dat','%c%*[^\n]')
Read file as a fixed format file while skipping the doubles
[names,types,y,answer] = textread('mydata.dat','%9c%5s%*f%2d%3s');
Read file and match Type literal
[names,typenum,x,y,answer]=textread('mydata.dat','%sType%d%f%d%s');
Read m-file into cell array of strings
file = textread('fft.m','%s','delimiter','\n','whitespace','');
To read all numeric data from a delimited text file, use a single output
argument, empty format string, and the appropriate delimiter. For
example, suppose data.csv contains:
1,2,3,4
5,6,7,8
9,10,11,12
Read the whole matrix into a single variable:
[data] = textread('data.csv','','delimiter',',');
Read the first two columns into two variables:
[col1, col2] = textread('data.csv','%n%n%*[^\n]','delimiter',',');
For files with empty cells, use the emptyvalue parameter. Suppose
data.csv contains:
1,2,3,4,,6
7,8,9,,11,12
Read the file like this, using NaN in empty cells:
[data] = textread('data.csv','','delimiter',',','emptyvalue',NaN);
The TEXTSCAN function is intended as a replacement for both STRREAD and
TEXTREAD.
>> [name1,value1,name2,value2]=textread('e:\test1.txt','%s %f %s %f','delimiter',',')
name1 =
' 货币资金'
' 应收票据'
' 应收账款'
'减:坏账准备'
'应收账款净额'
' 其他应收款'
' 预付账款'
' 存 货'
' 待摊费用'
' 流动资产合计'
value1 =
6865234
72120
38050
0
38050
0
26600
281950
100
7284054
name2 =
' 短期借款'
'应付票据'
' 应付账款'
' 预收账款'
' 应付工资'
' 应付福利费'
' 应交税金'
' 应付股利'
' 其他应付款'
' 预提费用'
value2 =
120000
85500
80200
0
0
8430
24420
34000
0
1600
>>
读取第一行
>> [name1,value1,name2,value2]=textread('e:\test1.txt','%s %f %s %f',1,'delimiter',',')
name1 =
' 货币资金'
value1 =
6865234
name2 =
' 短期借款'
value2 =
120000
>>
前2行
>> [name1,value1,name2,value2]=textread('e:\test1.txt','%s %f %s %f',2,'delimiter',',')
name1 =
' 货币资金'
' 应收票据'
value1 =
6865234
72120
name2 =
' 短期借款'
'应付票据'
value2 =
120000
85500
>>
发表评论
-
R语言与数据分析
2015-05-15 20:58 2066当今计算机系统要处理的数据类型变得多种多样,并且为了深入理 ... -
机器学习实践指南:案例应用解析
2014-04-17 19:53 1005试读及购买链接 《机器 ... -
matlab-矩阵合并
2013-06-10 13:56 3128a = 1 2 3 2 -
人工智能与数据分析所需要的知识
2013-04-30 18:27 292想较好得在数据分析和人工智能相关领域发展,最好具备以下基础: ... -
麦哈普的AI乐园【myhaspl@qq.com】我的另一个博客(机器学习、数据分析、智能计算的原创)
2013-04-28 10:52 11http://blog.csdn.net/u0102556 ... -
R-并行计算
2013-04-28 10:50 6064啊。。。找了一下,R 居然真的有办法可以多cpu平行运算!! ... -
谱聚类
2013-04-11 10:44 26681. 谱聚类 给你博客园上若干个博客,让你将它 ... -
对变化建模-用差分方程-动力系统及常数解
2013-04-09 15:24 1385差分表示在一个时间周期里考察对象的变化量。 差分表示在一个时 ... -
逻辑斯蒂映射-伪随机数
2013-04-04 15:28 3310逻辑斯蒂映射的形式为 x_(n+1)=ax_n( ... -
matlab-多项式乘除法及式子和导数
2013-03-21 15:06 4585>> a=[22 12 4 54] ... -
matlab-数组-元胞数据与结构数组
2013-03-20 17:45 3226y、z是元胞数组,num2cell完成由数值数组到元胞数组的 ... -
矩阵-范数
2013-03-13 17:30 1850>> a a = 12 33 ... -
向量-范数
2013-03-13 16:06 2270>> b=a(3,:) b = 22 ... -
矩阵-求逆
2013-02-27 15:51 2463设R是一个交换环,A是 ... -
lisp-猜数字算法与全局函数、变量
2013-01-30 17:55 1608* (defvar *big* 100) *BIG* ... -
开源 Lisp 相关项目
2013-01-19 22:38 3850IOLib 项目 (http://common-lisp.n ... -
四分位数求法
2012-11-22 20:18 2793四分位数间距:是上四分位数与下四分位数之差,用四分位数间距可反 ... -
matlab-神经网络-自定义多层感知器解决异或(2)
2012-10-10 22:33 2452继续定义单元神经元 net.inputs{i}.ran ... -
matlab-神经网络-自定义多层感知器解决异或(1)
2012-10-09 22:41 5134>> net=network net = ... -
matlab-模态对话框
2012-10-05 16:59 3483modal dialog box with the comm ...
相关推荐
介绍了Matlab中常用的textread和textscan函数的使用,通过实例演示文件文本的读取
Using file io functions in Matlab is a bit of confusion due to the variety and the issue of vectorisation. In the following snippet data is read back using: fscanf : creates a vector row by row ...
如何读取数据textread,例如通过xin textread( x_inlet.txt )我们可以把文件x_inlet.txt中的数据存储到数组xin中,且xin的维数和大小会自动与文件x_inlet.txt的相匹配。 如何设定坐标轴范围和坐标间距axis,set 例如 ...
matlab经常要读取数据。使用textread函数,可以方便的读取各种形式并不一致的文件。
matlab中textread的样例 基本各种用法都有,自己试验过,可以通过运行。适合初学者,或者调用函数的工程师。
MATLAB实现txt文本数据分离 部分源码 clear;clc A=textread('1.txt','%s'); %读入原始的文本,请查看变量A的结构 k=1; for i=1:2:length(A) %从A中把字符串提取出来 text{k}=A{i}; k=k+1; end
此函数读取几乎所有大小的文本文件。 对行数和克隆数没有限制,因为您知道文件中的克隆数。 此功能对于读取麻烦的 ASCII 文件最有用。
如果未指定行数,或者 TXT2MAT 不可用,则该函数使用 TEXTREAD 读取文件并自动确定输入数据的行数和列数。 输入: 文件——字符串变量; 完全指定的文件名nrows -- 数值标量; 数据文件中的行数flagstr -- 'fast' ...
1.读取数据:在Matlab中调用textread可读取UCI数据集,这里读取的文件是iris.data,因为文件中以逗号为分隔符,所以还要在读取方法中添加参数“‘delimiter’,‘,’”,从而在读数据的时候自动跳过分隔符。...
matlab sin函数源码 MATLAB Notes by WENQI 该笔记记录本人在科研过程中所学到的MATLAB实用操作,为方便查阅总结如下,代码都经过本人验证实用,由于来源广泛,未能列全参考文献。 与系统交互 直接使用bat命令 ...
放大法放大人gtr而他热突然突然饿啊特哇特爱饿哇reward饿傲天饿啊饿啊
读obsdata.txt的时候用matlab的textread()一个一个的读,然后根据epoch.txt知道每秒多少个卫星,由于每个卫星有8个数据,所以按照8个一循环读取。KMIT2000.20o文件到第37681秒数据之前都是好的,该行之后文件格式...
从该集合中下载文件,或者如果您决定使用其他嵌入文件,请注意,matlab文件中的嵌入矩阵需要与词汇表对齐,然后进行标准化,如下面的代码所示。 word=textread('$(VOCAB_500K_FILE)', '%s'); load('$(EM
并不真正需要它自己的功能,但它使使用“textread”更容易。
textread() 的包装器,它会自动为您生成格式字符串(每列都是数字或字符串); 将数据放入一个结构体,其中的字段以文件标题行给出的列名命名。 已使用 36 列数据文件。 主要基于解决方案编号 26207,但这需要您知道...
将字符图像进行二值化操作,将图像上的像素点的灰度值设置为0或255,也就是将整个图像呈现出明显的黑白效果的过程,而在Matlab中,一幅二值图像是一个取值只有0和1的逻辑数组。通常做法是先把彩色图像转化为灰度图像...
文件 fex.txt 具有“高”布局,可以使用 [t,id,rank,file,fcat,down] = textread('fex.txt',' s\t%d\t%d\t%d\t%d\t%d','delimiter' ,'\n'); time = datenum(t,'dd-mmm-yyyy HH:MM:SS'); 其中 id 和 rank 是 FEX ...
1.修改globals.m中的一些全局变量(主要是目录设定) cachedir= 'D:\DPMtrain\VOCCache\'; % 训练好的模型结果和中间数据的文件目录,此目录可以自己任意指定 tmpdir ='D:\DPMtrain\VOCtemp\'; % 训练中用到的临时文件...
潮流程序代码,MATLAB,仿真计算,电力系统稳态。电力系统暂态。电力系统方向。function []= fromY1(filename); clc;%清除指令窗口 tic; data=textread('4.txt'); %%读取系统参数 nodeNum=data(1,1); lineNum=data...
TE process数据集 包含21个类别的训练数据和测试数据 内容非常全面,内容格式为.dat文件,可使用textread函数直接导入到matlab中