Matlab图标关联修复
在更新matlab后将旧版本的matlab卸载后会出现所有相关文件都失去关联的情况,如果强行使用matlab打开的话会导致所有的相关文件图标都变成matlab应用的图标,十分难看,而且没有辨识度,无法通过图标区分m文件simulink文件等。
该问题可以通过修改注册表实现:
-
打开matlab
-
创建一个空script
-
输入下面内容
function associateFiles(action, userExtList, fileStr)
% associateFiles(action, extList, fileStr)
%
% Makes a registry files that can be used to set correct file associantions on
% a windows platform. The following MATLAB file extensions are supported:
% .m, .mat, .fig, .mexw32, .mexw64, .p, .mdl, .mdlp, .slx, .mldatx, .req,
% .sldd, .slddc, .slxp, .sltx, .mn, .mu, .muphlp, .xvc, .xvz, .ssc, .mlapp,
% .mlappinstall, .mltbx, .mlpkginstall, .mlprj
%
% INPUT:
% action - optional string.
% * 'add' (default) adds/rewrites the MATLAB file association registry
% keys for this version.
% * 'delete' deletes the MATLAB file association registry entries for
% ALL versions of MATLAB (including "old style" ones)
% * 'deleteadd' is the same as 'delete' followed by 'add'
% extList - optional string or cell array of strings containing the file
% extensions that should be associated with this version. Default is
% all MATLAB file extension (see above).
% fileStr - optional string with the name of the registry file to be written
% (possibly including path). Default is the file
% 'MatlabFileAssocFix.reg' in the current directory.
%
% USAGE:
% 1) Run with desired options (see above). A registry file should have been
% created.
% 2) Exit all running instances of MATLAB.
% 3) Make a backup copy of the windows registry if you need to restore the
% changes, see https://support.microsoft.com/en-us/kb/322756
% 4) Double click on the created file (possibly need to enter a password) and
% confirm.
% 5) Restart Windows (or explorer.exe).
% 6) The MATLAB files should now be associated with the MATLAB version that the
% registry file was created in and e.g. m-files should be opened in an
% already running instance of MATLAB.
%
% EXAMPLES:
% * associateFiles('deleteadd') - Makes a registry files that deletes all
% previous MATLAB file association registry keys and write new ones that
% associates all MATLAB files with the MATLAB version that the registry file
% was created in.
% * associateFiles('', {'.m', '.mat', '.fig'}, 'myFile') - Makes a registry file
% "myFile.reg" that associates m-, mat- and fig-files with the MATLAB version
% that the registry file was created in.
%
% VERSION 1.0
% Defualt input
if (nargin < 1 || isempty(action))
action = 'add';
end
if (nargin < 2)
userExtList = {};
end
if (nargin < 3)
fileStr = '';
end
if (~iscell(userExtList))
if (isempty(userExtList))
userExtList = {};
else
userExtList = {userExtList};
end
end
% Sanity check
if (~ischar(action) || (~strcmpi(action, 'add') && ...
~strcmpi(action, 'delete') && ~strcmpi(action, 'deleteadd')))
error('The action to perform must be ''add'', ''delete'' or ''deleteadd''!')
end
if (~isempty(userExtList) && ~min(cellfun(@ischar,