使用matlab创建新的blank.txt文件
如何创建一个空白的.txt文件?我使用Matlab R2014a。使用matlab创建新的blank.txt文件,matlab,createfile,Matlab,Createfile,如何创建一个空白的.txt文件?我使用Matlab R2014a。 我想检查指定名称的文件是否存在,如果不存在,我想创建一个 我不喜欢只回答“问”而不回答“我试过……”的问题 然而,有很多方法可以实现你的要求。这是其中之一: if exist('text.txt', 'file') == 0 disp('File does not exist, creating file.') f = fopen( 'text.txt', 'w' ); fclose(f); else disp
我想检查指定名称的文件是否存在,如果不存在,我想创建一个 我不喜欢只回答“问”而不回答“我试过……”的问题 然而,有很多方法可以实现你的要求。这是其中之一:
if exist('text.txt', 'file') == 0
disp('File does not exist, creating file.')
f = fopen( 'text.txt', 'w' );
fclose(f);
else
disp('File exists.');
end
要检查文件是否存在,只需使用以下命令: 要创建空文件,只需使用和:
这很容易用谷歌搜索。。为什么不首先使用这个工具(谷歌)呢?好的,但是你能展示你已经尝试过的东西吗?你怎么能覆盖现有的文件?
exist( filename, 'file' )
if ~exist(filename, 'file' )
fid = fopen(filename,'w');
fclose(fid);
end