MATLAB中,函数textscan和textread的区别

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 06:57:39

MATLAB中,函数textscan和textread的区别
MATLAB中,函数textscan和textread的区别

MATLAB中,函数textscan和textread的区别
textscan更适合读入大文件;
textscan可以从文件的任何位置开始读入,而textread 只能从文件开头开始读入;
textscan也可以从上一次textscan结束的位置开始读入,而textread不能;
textscan只返回一个数组,而textread要返回多个数组;
textscan提供更多转换读入数据的选择;
textscan提供给用户更多的配置参数.
总之就是说textscan比textread要牛.
参考:
# The textscan function offers better performance than textread, making it a better choice when reading large files.
# With textscan, you can start reading at any point in the file. Once the file is open, (textscan requires that you open the file first), you can seek to any position in the file and begin the textscan at that point. The textread function requires that you start reading from the beginning of the file.
# Subsequent textscans start reading the file at the point where the last textscan left off. The textread function always begins at the start of the file, regardless of any prior textread.
# textscan returns a single cell array regardless of how many fields you read. With textscan, you don't need to match the number of output arguments to the number of fields being read as you would with textread.
# textscan offers more choices in how the data being read is converted.
# textscan offers more user-configurable options.