[英]Matlab textscan gone wrong: cellfun to select data from certain lines
[英]matlab textscan gives me wrong number of lines
我在https://www.dropbox.com/s/vtby4027rvprhga/inputR_revised.tsv?dl=0上有一个文件名inputR_revised.tsv
在matlab中,我输入
fid=fopen('BMC3C/example/inputR_revised.tsv','r')
covTable = textscan(fid,['%s',repmat('%.8n',[1,20])],'HeaderLines',1);
我得到大小为41699乘以1的covTable {1,1}。但是,当我在终端上键入以下内容时
wc -l inputR_revised.tsv
我得到41677。为什么会有所不同? 我已使用sed和cut修改原始文件以获取inputR_revised.tsv。 这是原因吗?
有没有办法解决这个问题?
如果您打印的小数位数超过8位, %.8
是不够的。 对于这些情况,小数点后8位后的数字可被视为单独的条目。 这将使数量超出预期。 扫描格式中的小数位数应使用较高的值。 例如,
fid=fopen('BMC3C/example/inputR_revised.tsv','r')
covTable = textscan(fid,['%s',repmat('%.18n',[1,20])],'HeaderLines',1);
这应该为您提供正确的行数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.