- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望能够双击 .slx 文件并在 Simulink 中打开它。如果 MATLAB 已经打开,我希望它不要打开 MATLAB 的第二个实例。
挑战包括:
感谢可行的建议或示例
将 .slx 与 matlab.exe 关联起来如下所示:
我的 OSX 同行显示与此图标关联的 .slx:
最佳答案
遇到了同样的问题。这是 solution ,它适用于我的 R2018b。
在 Matlab 中运行此文件,它将生成可解决问题的 .reg 文件(当然要运行它)。然后重新启动您的 PC。
如果您不能(或不想)登录以下载文件,则这里是文件的代码:
function associateFiles(action, userExtList, fileStr)
% 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, userExtList)))
error('The file extension list must be a string or a cell array of strings!')
end
if (~ischar(fileStr))
error('The file to write to must be a string!')
end
% Get the currently running MATLAB version
verStr = regexp(version, '(\d*?\.\d*?\.\d*?)\.', 'tokens');
verStr = verStr{1}{1};
verNum = str2double(regexprep(verStr, '(\d*?\.\d*)[\x0000-\xffff]*', '$1'));
verHex = sprintf('%04x', str2double(regexprep(verStr, ...
'(\d*?)\.[\x0000-\xffff]*', '$1')), str2double(regexprep(verStr, ...
'\d*?\.(\d*?)\.[\x0000-\xffff]*', '$1')));
% Get 32/64-bit
arch = computer;
switch arch
case 'PCWIN'
binFolder = 'win32';
case 'PCWIN64'
binFolder = 'win64';
end
binPath = fullfile(matlabroot, 'bin', binFolder);
% Known MATLAB files with possible DDE actions
fileExtCell = {...
'fig' , 'MATLAB Figure' , '-62' , ...
{'Open', 'uiopen(''%1'',1)'} , [] ; ...
'm' , 'MATLAB Code' , '-58' , ...
{'Open', 'uiopen(''%1'',1)'} , {'Run', 'run(''%1'')'} ; ...
'mat' , 'MATLAB Data' , '-59' , ...
{'Load', 'load(''%1'')' } , {'Open', 'uiimport(''%1'')'}; ...
'mdl' , 'Simulink Model' , '-61' , ...
{'Load', 'uiopen(''%1'',1)'} , [] ; ...
'mdlp' , 'Simulink Protected Model' , '-72' , ...
[] , [] ; ...
'mexw32', 'MATLAB MEX' , '-63' , ...
[] , [] ; ...
'mexw64', 'MATLAB MEX' , '-63' , ...
[] , [] ; ...
'mn' , 'MuPAD Notebook' , '-66' , ...
{'Open', 'mupad(''%1'')'} , [] ; ...
'mu' , 'MuPAD Code' , '-67' , ...
{'Open', 'uiopen(''%1'',1)'} , [] ; ...
'muphlp', 'MuPAD Help' , '-68' , ...
{'Open', 'doc(symengine, ''%1'')'} , [] ; ...
'p' , 'MATLAB P-code' , '-60' , ...
[] , [] ; ...
'slx' , 'Simulink Model (SLX format)', '-73' , ...
{'Open', 'uiopen(''%1'',1)'} , [] ; ...
'ssc' , 'Simscape Model' , '-65' , ...
{'Open', 'uiopen(''%1'',1)'} , [] ; ...
'xvc' , 'MuPAD Graphics' , '-69' , ...
{'Open', 'mupad(''%1'')'} , [] ; ...
'xvz' , 'MuPAD Graphics' , '-70' , ...
{'Open', 'mupad(''%1'')'} , [] ; ...
'mlapp' , 'MATLAB Application' , [] , [], [] ; ...
'mltbx' , 'MATLAB Toolbox' , [] , [], [] ; ...
'mldatx' , 'Simulink Scenario' , [] , [], [] ; ...
'req' , 'Simulink Requirements Link' , [] , [], [] ; ...
'sldd' , 'Simulink Dictionary' , [] , [], [] ; ...
'slddc' , 'Simulink Dictionary' , [] , [], [] ; ...
'mlappinstall', 'MATLAB Application' , [] , [], [] ; ...
'mlpkginstall', 'MATLAB Support Package' , [] , [], [] ; ...
'slxp' , 'Simulink Protected Model Package', [] , [], [] ; ...
'sltx' , 'Simulink Template' , [] , [], [] ; ...
'mlprj' , 'MATLAB Project' , [] , [], []};
% Possibly trim list
if (~isempty(userExtList))
fileExtCell = fileExtCell(ismember(fileExtCell(:, 1), ...
regexprep(userExtList, '\.', '')), :);
end
% Make registry file
if (~isempty(fileStr))
% Possibly add file extension
[~, ~, tmp] = fileparts(fileStr);
if (isempty(tmp))
fileStr = [fileStr, '.reg'];
end
fid = fopen(fileStr, 'w');
else
fid = fopen('MatlabFileAssocFix.reg', 'w');
end
if (fid == -1)
error('Failed to create registry file')
end
% Write intial lines
fprintf(fid, '%s\r\n\r\n', 'Windows Registry Editor Version 5.00');
fprintf(fid, '%s\r\n\r\n', ';FIXES MATLAB FILE ASSOCIATIONS');
% REMOVE OLD KEYS
explorerKey = ['HKEY_CURRENT_USER\Software\Microsoft\Windows\', ...
'CurrentVersion\Explorer\FileExts'];
% Iterate over file extensions
for fileExtNo = 1 : size(fileExtCell, 1)
rmKeys = {};
fileExt = fileExtCell{fileExtNo, 1};
% File extension keys
[status, result] = dos(['reg query HKEY_CLASSES_ROOT /f .', fileExt, ...
' /k /e']);
if (~status)
keys = regexp(result, '(HKEY_CLASSES_ROOT[\x0000-\xffff]*?)\n', 'tokens');
rmKeys = [rmKeys, keys{:}];
end
% Old style keys without version numbers
if (~strcmpi(fileExt, 'mexw64'))
% Uses single DDE key for mex files
if (strcmpi(fileExt, 'mexw32'))
fileExtTmp = 'mex';
else
fileExtTmp = fileExt;
end
[status, result] = dos(['reg query HKEY_CLASSES_ROOT /f ', ...
fileExtTmp, 'file /k /e']);
if (~status)
keys = regexp(result, '(HKEY_CLASSES_ROOT[\x0000-\xffff]*?)\n', ...
'tokens');
rmKeys = [rmKeys, keys{:}];
end
end
% New style keys with version number
if (strcmpi(action, 'add'))
% Only remove keys related to this version
[status, result] = dos(['reg query HKEY_CLASSES_ROOT /f MATLAB.', ...
fileExt, '.', verStr ' /k']);
else
% Remove keys related to ALL version
[status, result] = dos(['reg query HKEY_CLASSES_ROOT /f MATLAB.', ...
fileExt, '. /k']);
end
if (~status)
keys = regexp(result, '(HKEY_CLASSES_ROOT[\x0000-\xffff]*?)\n', 'tokens');
rmKeys = [rmKeys, keys{:}];
end
% Explorer keys
[status, result] = dos(['reg query ', explorerKey, ' /f .', fileExt, ...
' /k /e']);
if (~status)
keys = regexp(result, '(HKEY_CURRENT_USER[\x0000-\xffff]*?)\n', 'tokens');
rmKeys = [rmKeys, keys{:}];
end
% Write to file
if (~isempty(rmKeys))
fprintf(fid, '%s\r\n\r\n', [';REMOVES ', upper(fileExt), ...
' FILE ASSOCIATIONS']);
for keyNo = 1 : length(rmKeys)
key = rmKeys{keyNo};
fprintf(fid, '%s\r\n\r\n', ['[-', key, ']']);
end
end
end
% ADD KEYS
if (~strcmpi(action, 'delete'))
% Get text Persistent Handler
[status, result] = dos(...
'reg query HKEY_CLASSES_ROOT\.txt\PersistentHandler /ve');
if (~status)
PersistentHandler = regexp(result, '\{[\x0000-\xffff]*?\}', 'match');
PersistentHandler = PersistentHandler{1};
else
PersistentHandler = '';
end
% DDE call
ddeCall = 'ShellVerbs.Matlab';
if (verNum > 8)
% Changed from R2013a
ddeCall = [ddeCall, '.', verStr];
end
% Default icon
defIcon = 'm';
if (~exist(fullfile(binPath, 'm.ico'), 'file'))
defIcon = '';
end
% Path to MATLAB binary directory with \\
binPathStr = regexprep(binPath, '\\', '\\\\');
% Write Shell Open key
key = ['[HKEY_CLASSES_ROOT\Applications\MATLAB.exe\shell\open', ...
'\command]%r', '@="\"', binPathStr, '\\MATLAB.exe\" \"%1\""%r%r'];
fprintf(fid, '%s\r\n\r\n', ';ADD SHELL OPEN');
lines = regexp(key, '([\x0000-\xffff]*?)%r', 'tokens');
for lineNo = 1 : length(lines)
fprintf(fid, '%s\r\n', lines{lineNo}{1});
end
% Iterate over file types
for fileExtNo = 1 : size(fileExtCell, 1)
fileExt = fileExtCell{fileExtNo, 1};
% File extension keys
key = ['[HKEY_CLASSES_ROOT\.', fileExt, ']%r@="MATLAB.', fileExt, '.', ...
verStr, '"%r'];
if (strcmpi(fileExt, 'm') && ~isempty(PersistentHandler))
% Add some values
key = [key, '"Content Type"="text/plain"%r', ...
'"PerceivedType"="Text"%r'];
end
key = [key, '%r'];
key = [key, '[HKEY_CLASSES_ROOT\.', fileExt, ...
'\OpenWithProgids]%r"MATLAB.', fileExt, '.', verStr, '"=""%r%r'];
if (strcmpi(fileExt, 'm') && ~isempty(PersistentHandler))
key = [key, '[HKEY_CLASSES_ROOT\.', fileExt, ...
'\PersistentHandler]%r@="', PersistentHandler, '"%r%r'];
end
key = [key, '[HKEY_CLASSES_ROOT\.', fileExt, ...
'\Versions\MATLAB.', fileExt, '.' verStr, ']%r"FileVersionMS"=dword:', ...
verHex, '%r"FileVersionLS"=dword:00000000%r%r'];
% DDE keys
ddeData = fileExtCell(ismember(fileExtCell(:, 1), fileExt), :);
key = [key, '[HKEY_CLASSES_ROOT\MATLAB.', fileExt, '.' verStr, ...
']%r@="', ddeData{2}, '"%r'];
if (~isempty(ddeData{3}))
key = [key, '"FriendlyTypeName"="@', binPathStr, '\\matlab.exe', ...
',', ddeData{3}, '"%r'];
end
key = [key, '%r'];
% Icon
icon = fileExt;
if (~exist(fullfile(binPath, [icon, '.ico']), 'file'))
icon = defIcon;
end
if (~isempty(icon))
key = [key, '[HKEY_CLASSES_ROOT\MATLAB.', fileExt, '.' verStr, ...
'\DefaultIcon]%r@="', binPathStr, '\\', icon, '.ico,0"%r%r'];
end
% Shell actions
for shellActionNo = 4:5
ddePar = ddeData{shellActionNo};
if (~isempty(ddePar))
key = [key, '[HKEY_CLASSES_ROOT\MATLAB.', fileExt, '.' verStr, ...
'\Shell\', ddePar{1}, ']%r@="', ddePar{1}, '"%r%r'];
key = [key, '[HKEY_CLASSES_ROOT\MATLAB.', fileExt, '.' verStr, ...
'\Shell\', ddePar{1}, '\command]%r@="\"', binPathStr, ...
'\\matlab.exe\""%r%r'];
key = [key, '[HKEY_CLASSES_ROOT\MATLAB.', fileExt, '.' verStr, ...
'\Shell\', ddePar{1}, '\ddeexec]%r@="', ddePar{2}, '"%r%r'];
key = [key, '[HKEY_CLASSES_ROOT\MATLAB.', fileExt, '.' verStr, ...
'\Shell\', ddePar{1},'\ddeexec\application]%r@="', ...
ddeCall, '"%r%r'];
key = [key, '[HKEY_CLASSES_ROOT\MATLAB.', fileExt, '.' verStr, ...
'\Shell\', ddePar{1},'\ddeexec\topic]%r@="system"%r%r'];
end
end
% Explorer keys
key = [key, '[', explorerKey, '\.', fileExt, '\OpenWithProgids]%r'];
if (strcmpi(fileExt, 'm'))
key = [key, '"m_auto_file"=hex(0):%r'];
end
key = [key, '"MATLAB.', fileExt, '.', verStr, '"=hex(0):%r%r'];
if (~isempty(ddeData{4}))
% Add key
key = [key, '[', explorerKey, '\.', fileExt, ...
'\OpenWithList]%r"a"="MATLAB.exe"%r"MRUList"="a"%r%r'];
else
key = [key, '[', explorerKey, '\.', fileExt, '\OpenWithList]%r%r'];
end
% Write to file
fprintf(fid, '%s\r\n\r\n', [';ADD ', upper(fileExt), ...
' FILE ASSOCIATIONS']);
lines = regexp(key, '([\x0000-\xffff]*?)%r', 'tokens');
for lineNo = 1 : length(lines)
fprintf(fid, '%s\r\n', lines{lineNo}{1});
end
end
end
% Cloese file
fclose(fid);
关于simulink - 如何将 .slx 文件与 Simulink 相关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35853781/
第一段代码工作正常,并给出了我需要的结果。我现在想做的是让它在 'as num' 上返回 3 个数字值对于“as num”上的 3 个不同值,对于同一列上的 3 个不同位置 SELEC
我想分析一些数据以编写定价算法。以下日期可用: 我需要三个变量/维度的函数/相关因子,它显示三个维度(pers_capacity、卧室数量、浴室数量)增长时中位数(价格)的变化。例如Y(#pers_c
正如标题所说 - 我的 Sprite Kit 游戏时不时地在后台崩溃,总是出现此错误 - Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Sub
假设我尝试保存以下数据,并且Songs模型的name属性上设置了Phalcon \ Mvc \ Model \ Validator \ PresenceOf验证器 // Get an existing
我有一个 if 控件,如下所示; if (Directory.Exists(System.IO.Path.Combine(systemPath, "Reports", companyName))
有人可以告诉我我们使用 ReadLine() 从文件 (.txt) 中读取特定行吗?现在我想读取文件的全部内容(不仅仅是第一行)。为此我需要使用什么方法。我用谷歌搜索了很多,但找不到解决方案。 我的代
我相信在大学时我用从 C 派生的语言为 FPGA 编写了一个程序。我了解 VHDL 和 verilog 等语言。但是,我不明白的是程序员在使用哪个方面有多少选择?它依赖于FPGA吗?我将使用 Xili
我有一个 if 控件,如下所示; if (Directory.Exists(System.IO.Path.Combine(systemPath, "Reports", companyName))
如何在运行时更改 Dashcode (Javascript) 中图像对象的源? 我试过: var image = document.getElementById("image").object;ima
我有几个相互关联的类,它们将被多种不同的算法使用 例子: struct B; struct A { B* parent; }; struct B { std::vector child
我正在开发一个网站,用户在客户收到的表中输入金额,如果任何客户没有提供分期付款(金额),则用户不会在表中输入任何金额,并且用户希望获取违约者的信息客户以10天为基础。所以我的问题是应该定义什么表和属性
我试图从上一个条目中选择一个值,并每次将该数字加一。我让它工作到选择当前条目值(默认 1000)并递增 1 并重新插入该值(因此每次最终都是 1001)。我需要它来选择该字段的最后一个条目,这样它将变
我不擅长“制作”查询。假设这是我的数据库: artist pics ------------------- -
最近,我要为我的网站做一个即时通知系统。我听说 COMET 在这种情况下必不可少。 我已经搜索 PHP 和 Comet 一段时间了,但是,我发现的指南和文章似乎只是循环中的 ajax 请求。例如,有一
我正在开发一款 iOS 游戏,我希望 clown 在场景外生成,然后向下移动。我的想法是全部创建它们,并将它们以 360 像素的距离放置在不可见的场景中。 像这样: SKSpriteNode *clo
我有以下子订单表。 mysql> select * from suborder; +-------------+------------------+ | order_state | bookin
这可能是一个有点初学者的问题,但考虑到在 Java 中调试编码是相当相关的:什么时候编码与 String 对象相关? 假设我有一个要保存到文件中的字符串对象。 String 对象本身是否使用某种我应该
首先我想说我是 CPP 的新手(我从 cpp11 开始):)考虑以下实体:学生(名字+姓氏)和组(描述+更多学生)。我在 C++ 中创建了以下 2 个类: class Student { privat
我正在尝试在单击该复选框时同步更新我的数据库。我决定使用 aJax,但它似乎无法识别 ajax。 代码:将成为 Switch_Active(this.id) 函数的元素 ... Deactivat
我正在创建一个菜单。菜单如下。 $('.category').mouseover(function() { $(this).removeClass('category').addClass('cate
我是一名优秀的程序员,十分优秀!