Matlab中读取txt文本文档

一、纯数据文件(没有字母和中文,纯数字)

对于这种txt文档,从matalb中读取就简单多了

例如test.txt文件,内容为

17.901 -1.1111 33.045
17.891 -1.1286 33.045
17.884 -1.1345 33.045

可以在command window中输入load test.txt ,然后就会产生一个test的数据文件,内容跟test.txt中的数据一样;另一种方法是在file/import data....../next/finish 也可产生一个叫test的数据文件。

二、中英文和数据如test1.txt

你好
欢迎来到
论坛
1 11 111 1111
2 22 222 2222
3 33 333 3333
4 44 444 4444
5 55 555 5555


这样的文件怎么读入数据呢?
方法有多种,现举两个比较简单实用的。

方法一:
file/import data....../next/finish
>> whos
Name           Size                   Bytes Class

data           5x4                      160 double array
textdata       4x1                      300 cell array

Grand total is 54 elements using 460 bytes

>> data

data =

           1          11         111        1111
           2      

你可能感兴趣的:(Matlab读取中文TXT)