simmechanics.zip


simmechanics.zip
资源截图
代码片段和文件信息
function install_addon(zip_file)
%
% INSTALL_ADDON Install the specified addon to the current MATLAB installation.
%   INSTALL_ADDON ZIP_FILE.ZIP Install the contents of ZIP_FILE to MATLABROOT.

%   Copyright 2008-2012 The MathWorks Inc.

% first check if the jvm is available
if (~usejava(‘jvm‘))
    error(‘install_addon requires Java to run.‘)
end

% check args
if (nargin ~= 1)
    error(‘Usage: install_addon ‘)
end

% check if archive exists
if (exist(zip_file ‘file‘) ~= 2) 
    error(‘Archive %s does not exist.
Installation failed.‘ zip_file)
end

% obtain addon name ver and arch from zip_file name
[~ zip_file_name ~] = fileparts(zip_file);
[addon_name remain] = strtok(zip_file_name ‘.‘);
[addon_rel remain] = strtok(remain ‘.‘);
addon_arch = strtok(remain ‘.‘);
% strip off ‘r‘ prefix from addon_rel
addon_rel = strtok(addon_rel ‘r‘);

msg = sprintf(‘Installing %s...‘ addon_name);
disp(msg)

% check addon arch against matlab arch
matlab_arch = computer(‘arch‘);
if (~strcmpi(matlab_arch addon_arch)) 
    error(‘Archive architecture (%s) does not match the MATLAB architecture (%s).
Installation of %s failed.‘ addon_arch matlab_arch addon_name)
end

% check addon ver against matlab ver
matlab_rel = version(‘-release‘); 
if (~strcmpi(matlab_rel addon_rel)) 
    error(‘Archive release (%s) does not match the MATLAB release (%s).
Installation of %s failed.‘ addon_rel matlab_rel addon_name)
end

% installing to matlabroot
install_dir = matlabroot;

% unzip zip file to install_dir
msg = sprintf(‘Extracting archive %s to %s...‘ zip_file install_dir);
disp(msg)
unzipped_files = unzip(zip_file install_dir);

% check if files were extracted from zip file
if (isempty(unzipped_files))
    error(‘No files were extracted from archive %s.
%s installation failed.‘ zip_file addon_name)
end

% fix permissions on extracted files - make files writable
for i = 1:length(unzipped_files)
    file = unzipped_files{i};
    fileattrib(file ‘+w‘);
end

% add directories from addon .phl file to pathdef.m current path
msg = sprintf(‘Adding directories for %s to path...‘ addon_name);
disp(msg)

% stash current path pathdef before re-creating pathdef
current_path = path;
saved_path = pathdef;

% turn off duplicate path warning before modifying path 
w_state = warning(‘off‘ ‘MATLAB:dispatcher:pathWarning‘);

% recreate pathdef to get newly added .phl file into pathdef
restoredefaultpath;
path(saved_path path);
if (savepath ~= 0)
    disp(‘Warning: Unable to save modified path to file.‘)
    msg = sprintf(‘To have %s on the path for future MATLAB sessions you will need to save the path to a different file.‘ addon_name);
    disp(msg)
end

% rebuild current path with newly added paths
path(current_path path);

% restore duplicate path warning
warning(w_state);

% Refresh docroot in case new doc directories were added
docroot(docroot);

% Make changes for doc center to work
destination = com.mathworks.install.command.doc.BuildSh

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        3343  2016-04-27 14:16  install_addon.m
     目录           0  2016-05-03 10:47  smlink.r2014a.win64
     目录           0  2014-02-28 00:26  smlink.r2014a.win64in
     目录           0  2014-02-28 00:26  smlink.r2014a.win64in
egistry
     文件        1339  2014-01-29 23:38  smlink.r2014a.win64in
egistrypmi_mli.xml
     目录           0  2014-02-28 00:26  smlink.r2014a.win64inwin64
     文件      641536  2014-01-30 11:54  smlink.r2014a.win64inwin64cl_inventor2sm.dll
     文件     1800704  2014-01-30 12:09  smlink.r2014a.win64inwin64cl_proe2sm.dll
     文件      476672  2014-02-21 12:02  smlink.r2014a.win64inwin64cl_sldwks2sm.dll
     文件       49664  2014-01-30 11:07  smlink.r2014a.win64inwin64pmi_api.dll
     文件      231936  2014-01-30 11:00  smlink.r2014a.win64inwin64pmi_csts2connections.dll
     文件      261120  2014-01-30 11:21  smlink.r2014a.win64inwin64pmi_mli.dll
     文件      752128  2014-01-30 11:06  smlink.r2014a.win64inwin64pmi_toolkit.dll
     目录           0  2014-02-28 00:26  smlink.r2014a.win64help
     目录           0  2014-02-28 00:26  smlink.r2014a.win64helpphysmod
     目录           0  2014-02-28 00:26  smlink.r2014a.win64helpphysmodsmlink
     文件          85  2014-01-21 11:56  smlink.r2014a.win64helpphysmodsmlink_next.gif
     文件          85  2014-01-21 11:56  smlink.r2014a.win64helpphysmodsmlink_prev.gif
     文件       13746  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkcad-export-1.html
     文件       14200  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkcad-export-2.html
     文件       14205  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkcad-export-3.html
     文件       14892  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkcad-export-from-autodesk-inventor.html
     文件       15265  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkcad-export-from-creo-proengineer.html
     文件       16112  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkcad-export-from-solidworks.html
     文件       33149  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkcustom-cad-export-1.html
     文件          30  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkdoccenter.properties
     文件       36369  2014-01-21 11:55  smlink.r2014a.win64helpphysmodsmlinkdoccentertoc.html
     文件       36074  2014-01-21 11:56  smlink.r2014a.win64helpphysmodsmlinkdocscripts.js
     文件          80  2014-01-21 11:56  smlink.r2014a.win64helpphysmodsmlinkdocstyle.css
     目录           0  2014-02-28 00:26  smlink.r2014a.win64helpphysmodsmlinkexamples
     文件          85  2014-01-18 07:50  smlink.r2014a.win64helpphysmodsmlinkexamples_next.gif
............此处省略498个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)