Matlab中的转义字符 [英] Escape characters in Matlab
本文介绍了Matlab中的转义字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用fileread()读取文件,该文件将返回整个文件.现在,我需要逐行读取并将其转换为处理数据.我可以知道如何在Matlab中检测换行符吗?我尝试了"\ n"和"\ r \ n",但它不起作用.
I am reading a file using fileread() which returns me the entire file. Now I need to read line by line and convert them into process the data. Can I know how I would be able to detect the newline character in Matlab? I tried '\n' and '\r\n' and it doesn't work.
预先感谢
推荐答案
You can read the file line by line (see fgetl):
fid = fopen ( 'file', 'r' );
% Check that it opened okay
if fid ~= -1
while ( true )
line = fgetl ( fid );
% Check for end of file
if line == -1; break; end
%Do stuff with line;
end
fclose ( fid );
end
这篇关于Matlab中的转义字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文