FILE_SIZE size in bytes of file

Contents

Inputs

Outputs

function s = file_size(p)
arguments
  p string
end

s = NaN(size(p));

i = isfile(p);

if ~any(i)
  return
elseif isscalar(p)
  d = dir(p);
else
  d = arrayfun(@dir, p(i));
end

i = i & ~isempty(d);
s(i) = [d.bytes];

end