MATLAB Examples

filesize documentation

The filesize function returns the size of a file as a variable or prints it in the command line.

Contents

Syntax

filesize 'filename'
s = filesize('filename')

Description

filesize 'filename' displays the size of any file in the command window.

s = filesize('filename') writes the file size of filename to a variable s in the workspace. Output is in bytes.

Command window example:

How big is that cameraman.tif file?

filesize cameraman.tif
cameraman.tif is 65.24 KB.

Variable example:

Alternatively, write it to a variable, which will be in units of bytes:

s = filesize('cameraman.tif')
s =
       65240

Author Info

This function was written by Chad A. Greene of the University of Texas at Austin, and the Institute for Geophysics (UTIG), April 2016. http://www.chadagreene.com