前言
通过.m判断文本中的数据是否为空,通过fgetl()函数获取的内容判断;
通过Matlab Function 也可以,程序相似;
1.判断文件是否为空
方法一,代码如下:
fid3 = fopen('E:\Out.txt','r');
ch = fgetl(fid3);
if ch == -1 %判断文件是否为空
fclose(fid3);
disp('empty')
end
方法二,代码如下:
fid = fopen('E:\Out.txt','r');
disp(~feof(fid)) %非空disp显示1
fclose(fid);