Matlab中读取文件中数据的函数用法
2016-09-17 19:20
253 查看
1、load()函数
文件sample_file.txt中的数据:
在MATLAB命令行中运行结果:
>> M=load('sample_file.txt')
M =
1 5 4 16 8
5 43 2 6 8
6 8 4 32 1
90 7 8 7 6
5 9 81 2 3
2、importdata()函数
>> data=importdata('sample_flie_plus5.mat')
data =
6 10 9 21 13
10 48 7 11 13
11 13 9 37 6
95 12 13 12 11
10 14 86 7 8
>> D = importdata('sample_file2.txt')
D =
data: [4x3 double]
textdata: {7x4 cell}
>> data=D.data
data =
1 4 612
1 4 613
1 4 614
1 4 615
>> text=D.textdata
text =
'This is a file h...' [] [] []
'This is file is ...' [] [] []
'col1' 'col2' 'col3' 'col4'
'A' '' '' ''
'B' '' '' ''
'C' '' '' ''
'D' '' '' ''
3、textread()函数
'sample_file2.txt'文件:
此处headerlines 及3的含义是:从文件读取内容时忽略掉前3行
>> [c2 c3 c4]=textread('sample_file2.txt','%*s %d %d %f','headerlines',3)
c2 =
1
1
1
1
c3 =
4
4
4
4
c4 =
612
613
614
615
文件sample_file.txt中的数据:
在MATLAB命令行中运行结果:
>> M=load('sample_file.txt')
M =
1 5 4 16 8
5 43 2 6 8
6 8 4 32 1
90 7 8 7 6
5 9 81 2 3
2、importdata()函数
>> data=importdata('sample_flie_plus5.mat')
data =
6 10 9 21 13
10 48 7 11 13
11 13 9 37 6
95 12 13 12 11
10 14 86 7 8
>> D = importdata('sample_file2.txt')
D =
data: [4x3 double]
textdata: {7x4 cell}
>> data=D.data
data =
1 4 612
1 4 613
1 4 614
1 4 615
>> text=D.textdata
text =
'This is a file h...' [] [] []
'This is file is ...' [] [] []
'col1' 'col2' 'col3' 'col4'
'A' '' '' ''
'B' '' '' ''
'C' '' '' ''
'D' '' '' ''
3、textread()函数
'sample_file2.txt'文件:
此处headerlines 及3的含义是:从文件读取内容时忽略掉前3行
>> [c2 c3 c4]=textread('sample_file2.txt','%*s %d %d %f','headerlines',3)
c2 =
1
1
1
1
c3 =
4
4
4
4
c4 =
612
613
614
615
相关文章推荐
- 在Java中如何读取用MATLAB的fwrite()函数写入文件的数据
- 利用COM组件IPicture读取jpg、gif、bmp图片文件数据和显示图片的两个函数
- matlab中读取某个文件夹下所有数据文件
- 如何将视差数据保存为 txt 数据文件以便在 Matlab 中读取分析?
- matlab中读取txt数据文件(转)
- ifstream(一)之 eof() 函数——解决读取文件最后一个数据多读一次的方法
- 在MATLAB中读取二进制数据文件
- JXTree对象,读取外部xml文件数据,生成树的函数
- matlab各种数据类型的文件的读取与写入方法
- C语言学习10:结构体,结构体应用,联合用法,枚举,fopen函数使用,fseek,ftell的作用和文件结束符EOF,数组和文件交换数据,个人信息管理。
- Matlab读取和保存TXT文件数据
- matlab中如何读取TXT数据文件
- matlab中读取txt数据文件(txt文本文档)
- MATLAB:从fig文件中读取数据
- JXTree对象,读取外部xml文件数据,生成树的函数
- matlab中如何读取TXT数据文件 (续)
- Matlab中如何读取TXT数据文件[转载]
- matlab处理txt文本文件---数据格式要有规律性,否则要用编写特定方式进行读取
- Matlab读取txt中用空格分隔的数据文件到矩阵
- MATLAB处理txt文本文件---数据格式要有规律性,否则要用编写特定方式进行读取