Programming |
Creating and Uncompressing Zip Archives
Using the zip
and unzip
functions, you can compress and uncompress files and directories. The zip
function compresses files or directories into a zip archive. The unzip
function uncompresses zip archives.
Example -- Using the zip Function
Again building on the example from previous sections, the following code creates a zip archive of the retrieved Web page:
%The urlread function loads the contents of the Web page into the %MATLAB workspace. recentFile = urlread('http://www.mathworks.com/matlabcentral/fileexchange/lo adFileList.do?objectType=fileexchange&orderBy=date&srt3=0'); %The findstr function searches for the word "Simulink". hits = findstr(recentFile,'Simulink'); %The if statement checks for any hits. if(isempty(hits) == 0) %If there are hits, the Web page will be saved locally using the %urlwrite function. urlwrite('http://www.mathworks.com/matlabcentral/fileexchange/l oadFileList.do?objectType=fileexchange&orderBy=date&srt3=0','co ntains_simulink.html');%The zip function creates a zip archive of the retrieved Web page.
zip('simulink_matches.zip','contains_simulink.html');
end;
Downloading Web Content and Files | Sending E-Mail |
© 1994-2005 The MathWorks, Inc.