Main Content


Extract contents of zip file



unzip(zipfilename) extracts the archived contents of zipfilename into the current folder, preserving the attributes and timestamps of each file. unzip can extract files from your local system or from an Internet URL.

If a file exists with the same name and the file is not read-only, MATLAB® overwrites it. Otherwise, MATLAB issues a warning. On Microsoft® Windows® platforms, the hidden, system, and archive attributes are not set.


unzip(zipfilename,outputfolder) extracts zipfilename into outputfolder. If outputfolder does not exist, MATLAB creates it.


filenames = unzip(___) returns a cell array of character vectors containing the names of the extracted files.


collapse all

Create a zip file and extract it to the folder archive.

Create the zip file containing example MAT-files.


Extract to the folder archive.

exampleFiles = unzip('','archive')
exampleFiles = 1×7 cell
    {'archive\chirp.mat'}    {'archive\gong.mat'}    {'archive\handel.mat'}    {'archive\laughter.mat'}    {'archive\mtlb.mat'}    {'archive\splat.mat'}    {'archive\train.mat'}

Download and extract a zip file from a URL to a local folder.

Suppose you have the zip file stored at the URL Download and extract the file to the desired local folder, example_folder.

url = '';
unzip(url, 'example_folder');

Input Arguments

collapse all

Name of zip file to extract from, specified as a character vector or a string scalar. If zipfilename has no extension, MATLAB searches for zipfilename appended with .zip.

zipfilename must include a path relative to the current folder or an absolute path.

If zipfilename is a URL, zipfilename must include the protocol type (for example, http://). MATLAB downloads the URL to the temporary folder on your system, and then it deletes the URL on cleanup.

unzip does not support password-protected or encrypted zip archives.

Data Types: char | string

Target folder for the extracted files, specified as a character vector or a string scalar.

Data Types: char | string

Output Arguments

collapse all

Names of extracted files, returned as a cell array of character vectors. If outputfolder specifies a relative path, filenames contains the relative path. If outputfolder specifies an absolute path, filenames contains the absolute path.


  • To extract a zip file that contains non-7-bit ASCII characters, extract the file on a machine that has the appropriate language/encoding settings.

Version History

Introduced before R2006a

expand all