Skip to content

Instantly share code, notes, and snippets.

@robertoostenveld
Created November 21, 2018 09:25
Show Gist options
  • Save robertoostenveld/d3400ae756098138532a65f75133de18 to your computer and use it in GitHub Desktop.
Save robertoostenveld/d3400ae756098138532a65f75133de18 to your computer and use it in GitHub Desktop.
MATLAB function to truncate the content of a file
function truncate(filename)
% TRUNCATE a file to 0 bytes, i.e. replace the file with an empty one
%
% Use as
% truncate(filename)
assert(exist(filename,'file'), 'file does not exists');
fid = fopen(filename, 'w');
fclose(fid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment