This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Extract contents of zip file


filenames = unzip(zipfilename,outputdir)


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

unzip(zipfilename,outputdir) extracts the contents of zipfilename into the folder outputdir.

filenames = unzip(zipfilename,outputdir) returns the names of the extracted files in the cell array of character vectors, filenames. Specifying outputdir is optional.

Input Arguments


Name of the zip file, specified as a character vector.

If zipfilename does not include the full path, unzip searches for the file in the current folder and along the MATLAB® path. If you do not specify the file extension, unzip appends .zip.

If you are downloading a URL, zipfilename must include the protocol type (for example, http://). The unzip function downloads the URL to the temporary folder on your system, and deletes the URL on cleanup.


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

Default: current folder ('.')

Output Arguments


Cell array of character vectors that contains the paths of the extracted files.

If outputdir specifies a relative path, filenames contains the relative path. If outputdir specifies an absolute path, filenames contains the absolute path.


Copy the example MAT-files to the folder archive:

% Zip the example MAT-files to

% Unzip to the folder 'archive'

Download Cleve Moler's "Numerical Computing with MATLAB" examples to the output folder ncm:

url ='';
ncmFiles = unzip(url,'ncm')


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

  • If any files in the target folder have the same name as files in the zip file, and you have write permission to the files, unzip overwrites the existing files with the archived versions. If you do not have write permission, unzip issues a warning.

  • Extract files that contain non-7-bit ASCII characters on a machine that has the appropriate language/encoding settings.


To extract files from a zip file using the Current Folder browser, select the zip file, right-click to open the context menu, and then select Extract.

See Also

| | | | |

Introduced before R2006a

Was this topic helpful?