There are a few reasons why "Error 5" may occur:
This error can occur when attempting to install MATLAB 64-bit on a 32-bit operating system.
MATLAB 64-bit cannot be installed on Windows 32-bit, even if your processor is 64-bit.
SOLUTION: Install MATLAB 32-bit (R2015b or earlier).
Corrupt Download / Antivirus Software
This error can occur if the installation files are corrupt.
Antivirus software will sometimes scan and corrupt downloaded files.
SOLUTION: Temporarily disable any antivirus software and download a new copy of the installer.
Attempting to run installer without extracting from zip
This error can occur if the installer executable (setup.exe) was not extracted from the zip.
The installation files come packaged in a WinZip self-extractor (matlab_r20xxx_installer.exe) and the files must first be extracted.
SOLUTION: Right-click on the zip, select 'Extract to' from the WinZip menu, and choose an empty destination folder. Once the zip file has been extracted, run the installer executable (setup.exe) from the new folder.
This error can occur if the setup.exe file does not have sufficient permissions to run.
SOLUTION: Navigate to the folder where setup.exe was extracted (typically _temp_matlab_R20xxx_win64) and right-click on setup.exe and select "Run as administrator". If you do not have administrator privileges, please contact your IT department for further information on obtaining these privileges and installing software.