This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
MATLAB has a limited list of pre-defined countries for which it sets the default paper type to "A4" and default paper units to "centimeters". For all other countries, "usletter" and "inches" will be used respectively. These settings are created in the "hgrc.m" file.
There are two methods to resolve this issue and set the default value of these properties for your system.
1. If you are an individual user, especially on a network installation of MATLAB, it is recommended that you add the following line in your "startup.m" file (if a "startup.m" file does not exist on your system, create a new one and place it on the MATLAB path):
set(0,'DefaultFigurePaperType','A4')
set(0,'DefaultFigurePaperUnits','centimeters')
This method is preferred for individual users since it will carry over between releases of MATLAB (upgrading MATLAB will preserve your "startup.m" file, but will over-write "hgrc.m"). This also allows "hgrc.m" and "matlabrc.m" to be used by network administrators to make system-wide changes without over-writing individual users' settings. This setting is also independent of your system's country setting, thus, even if your country is set to US, you can still use this method to set the default paper type and paper units in MATLAB.
2. If you are a network administrator and want to make a system-wide change, you can edit the "hgrc.m" file. The list of countries for which MATLAB sets the paper size to "A4" can be found in this file. To add your country code to this list, follow these steps:
a. Find the two-letter ISO 3166 short name for your country, i.e., the ISO 3166-1-alpha-2 code which can be found at the following address:
b. Type "edit hgrc" at the MATLAB prompt. (For reference, the "hgrc.m" file resides in $MATLAB\toolbox\local\, where $MATLAB is the MATLAB root directory; the file can be located on your system by typing "which hgrc" at the MATLAB prompt).
c. Scroll down to the line that reads
if usejava('jvm') && ~exist('defaultpaper','var')
if any(strncmpi(char(java.util.Locale.getDefault.getCountry), ...
{'gb', 'uk', 'fr', 'de', 'es', 'ch', 'nl', 'it', 'ru',...
'jp', 'kr', 'tw', 'cn', 'cz', 'sk', 'au', 'dk', 'fi',...
'gr', 'hu', 'ie', 'il', 'in', 'no', 'pl', 'pt',...
'ru', 'se', 'tr', 'za'},2))
defaultpaper = 'A4';
defaultunits = 'centimeters';
end
end
d. You need to add your country code to this list. For example, if you were adding Liechtenstein (ISO 3166 code "li"), you would edit this code to read:
if usejava('jvm') && ~exist('defaultpaper','var')
if any(strncmpi(char(java.util.Locale.getDefault.getCountry), ...
{'gb', 'uk', 'fr', 'de', 'es', 'ch', 'nl', 'it', 'ru',...
'jp', 'kr', 'tw', 'cn', 'cz', 'sk', 'au', 'dk', 'fi',...
'gr', 'hu', 'ie', 'il', 'in', 'no', 'pl', 'pt',...
'ru', 'se', 'tr', 'za','li'},2))
defaultpaper = 'A4';
defaultunits = 'centimeters';
end
end
e. Save the file.
f. Exit MATLAB and restart for the changes to take effect.
Best Answer