Matlab – How to get the size of a file in MATLAB


What is the best way to figure out the size of a file using MATLAB? The first thought that comes to mind is size(fread(fid)).

Best Solution

Please see the dir function as stated above.

Please note that the dir function works on files and not on directories only.

>> s = dir('c:\try.c')

s = 

       name: 'try.c'
       date: '01-Feb-2008 10:45:43'
      bytes: 20
      isdir: 0
    datenum: 7.3344e+005