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.
String that specifies the name of the zip file.
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.
String that specifies the target folder for the extracted files.
Default: current folder ('.')
Cell array of strings that contain 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 examples.zip zip('examples.zip','*.mat',... fullfile(matlabroot,'toolbox','matlab','demos')) % Unzip examples.zip to the folder 'archive' unzip('examples','archive')
Download Cleve Moler's "Numerical Computing with MATLAB" examples to the output folder ncm:
url ='http://www.mathworks.com/moler/ncm.zip'; ncmFiles = unzip(url,'ncm')
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.
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.