Skip to content

Instantly share code, notes, and snippets.

@mattgaidica
Created November 26, 2018 01:26
Show Gist options
  • Select an option

  • Save mattgaidica/c8750ccae650318eb9271e6c0efbc52f to your computer and use it in GitHub Desktop.

Select an option

Save mattgaidica/c8750ccae650318eb9271e6c0efbc52f to your computer and use it in GitHub Desktop.
function r = formatBytes(bytes)
s = {'B', 'KB', 'MB', 'GB', 'TB'};
e = floor(log(bytes)/log(1024));
r = sprintf(['%.2f ',s{e+1}], (bytes/(1024^floor(e))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment