如何在脚本/函数中检查已安装的MATLAB工具箱?

时间:2022-10-02 06:59:53

How would one check for installed MATLAB toolboxes in a script/function? (checking toolbox versions would also be good!) This could provide a quick and useful error message when someone attempts to run a script without a required toolbox.

如何在脚本/函数中检查已安装的MATLAB工具箱?(查看工具箱版本也不错!)当有人试图在不需要工具箱的情况下运行脚本时,这可以提供一个快速而有用的错误消息。

A quick, albeit rough, solution that comes to mind is parsing the text output of the ver command. I wonder if there's a better way.

一个快速的、尽管粗糙的解决方案是解析ver命令的文本输出。我想知道有没有更好的办法。

Some quick searching revealed ver product or the license function with the 'test' argument may be useful, but I could not find a mapping of toolbox names (ie. 'Image Processing Toolbox') to product names (ie. 'control') or feature names (ie. image_toolbox).

一些快速搜索显示的ver产品或带有“test”参数的许可函数可能有用,但是我找不到工具箱名称的映射(例如)。“图像处理工具箱”)到产品名称(即。“控件”)或特性名称(例如。image_toolbox)。

Furthermore, when I ran license('inuse'), I only received the following:

此外,当我运行许可证(“inuse”)时,我只收到以下内容:

>> a = license('inuse'); a

a = 

    feature: 'matlab'
       user: <username>

I hoped for a list of the many toolboxes I have access to.

我希望能找到一份我能找到的许多工具箱的清单。

This question was prompted by trying to test a co-workers script early. Unfortunately, it required the Image Processing Toolbox, which I currently lack. A useful error message would've saved time trying to diagnose the problem. Now I'll wait for a compiled version before testing it.

这个问题是由于试图尽早测试同事的脚本而引起的。不幸的是,它需要图像处理工具箱,这是我目前缺少的。一个有用的错误消息可以节省诊断问题的时间。现在,我将等待一个编译后的版本,然后再测试它。

6 个解决方案

#1


26  

One drawback to the ver function is that it only tells you what's installed, not what has an available license. It's possible to have a toolbox installed and no license to use it (or all the available licenses could be checked out by other users). A better choice is the license function, which (as you pointed out) requires a unique "feature string" for each toolbox.

ver函数的一个缺点是它只告诉您安装了什么,而不告诉您有什么许可。安装一个工具箱并没有使用它的许可是可能的(或者其他用户可以检查所有可用的许可证)。一个更好的选择是许可函数,它(正如您指出的)要求每个工具箱都有一个惟一的“特性字符串”。

Here's an older list of feature strings for various toolboxes taken from a now-defunct newsgroup thread (link is now dead):

下面是一个旧的特性字符串列表,用于从一个现已失效的新闻组线程(link现在已经失效)中获取的各种工具箱:

featureStr = {'Aerospace_Blockset'; ...
              'Aerospace_Toolbox'; ...
              'Bioinformatics_Toolbox'; ...
              'Communication_Blocks'; ...
              'Communication_Toolbox'; ...
              'Compiler'; ...
              'Control_Toolbox'; ...
              'Curve_Fitting_Toolbox'; ...
              'Data_Acq_Toolbox'; ...
              'Database_Toolbox'; ...
              'Datafeed_Toolbox'; ...
              'Dial_and_Gauge_Blocks'; ...
              'Distrib_Computing_Toolbox'; ...
              'Econometrics_Toolbox'; ...
              'EDA_Simulator_Link_DS'; ...
              'Embedded_Target_c166'; ...
              'Embedded_Target_c2000'; ...
              'Embedded_Target_c6000'; ...
              'Embedded_Target_MPC555'; ...
              'Excel_Link'; ...
              'Filter_Design_HDL_Coder'; ...
              'Filter_Design_Toolbox'; ...
              'Fin_Derivatives_Toolbox'; ...
              'Financial_Toolbox'; ...
              'Fixed_Income_Toolbox'; ...
              'Fixed_Point_Toolbox'; ...
              'Fixed-Point_Blocks'; ...
              'Fuzzy_Toolbox'; ...
              'GADS_Toolbox'; ...
              'IDE_Link_MU'; ...
              'Identification_Toolbox'; ...
              'Image_Acquisition_Toolbox'; ...
              'Image_Toolbox'; ...
              'Instr_Control_Toolbox'; ...
              'Link_for_Incisive'; ...
              'Link_for_ModelSim'; ...
              'Link_for_Tasking'; ...
              'Link_for_VisualDSP'; ...
              'MAP_Toolbox'; ...
              'MATLAB'; ...
              'MATLAB_Builder_for_dot_Net'; ...
              'MATLAB_Builder_for_Java'; ...
              'MATLAB_Distrib_Comp_Engine'; ...
              'MATLAB_Excel_Builder'; ...
              'MATLAB_Link_for_CCS'; ...
              'MATLAB_Report_Gen'; ...
              'MBC_Toolbox'; ...
              'MPC_Toolbox'; ...
              'NCD_Toolbox'; ...
              'Neural_Network_Toolbox'; ...
              'OPC_Toolbox'; ...
              'Optimization_Toolbox'; ...
              'PDE_Toolbox'; ...
              'Power_System_Blocks'; ...
              'Real-Time_Win_Target'; ...
              'Real-Time_Workshop'; ...
              'RF_Blockset'; ...
              'RF_Toolbox'; ...
              'Robust_Toolbox'; ...
              'RTW_Embedded_Coder'; ...
              'Signal_Blocks'; ...
              'Signal_Toolbox'; ...
              'SimBiology'; ...
              'SimDriveline'; ...
              'SimElectronics'; ...
              'SimEvents'; ...
              'SimHydraulics'; ...
              'SimMechanics'; ...
              'Simscape'; ...
              'SIMULINK'; ...
              'Simulink_Control_Design'; ...
              'Simulink_Design_Verifier'; ...
              'Simulink_HDL_Coder'; ...
              'Simulink_Param_Estimation'; ...
              'SIMULINK_Report_Gen'; ...
              'SL_Verification_Validation'; ...
              'Spline_Toolbox'; ...
              'Stateflow'; ...
              'Stateflow_Coder'; ...
              'Statistics_Toolbox'; ...
              'Symbolic_Toolbox'; ...
              'SystemTest'; ...
              'Video_and_Image_Blockset'; ...
              'Virtual_Reality_Toolbox'; ...
              'Wavelet_Toolbox'; ...
              'XPC_Embedded_Option'; ...
              'XPC_Target'};

This covers many of the common ones, but isn't exhaustive and doesn't include feature strings for newer toolboxes. There doesn't appear to be any readily-available list of current feature strings for all MathWorks toolboxes. I believe you can find them on the "INCREMENT" lines in a license file, or (as vlee mentions in a comment) you can call a function from a given toolbox and then use license('inuse') to get the feature string from the displayed list of toolboxes currently being used. However, both of the above options require an available license already.

这涵盖了许多常见的功能,但并不详尽,也不包括新工具箱的特性字符串。对于所有MathWorks工具箱,似乎没有任何现成的当前特性字符串列表。我相信您可以在许可证文件的“增量”行中找到它们,或者(正如vlee在注释中提到的)您可以从给定的工具箱中调用一个函数,然后使用license('inuse')从当前使用的工具箱列表中获取特性字符串。但是,上述两个选项都需要一个可用的许可。

Using the above list of feature strings and the function license, you can check which toolboxes you have a license to use. The following code checks for licenses for the entire list above:

使用上面的特性字符串列表和函数许可,您可以检查您要使用哪个工具箱。下面的代码检查了上面整个列表的许可证:

index = cellfun(@(f) license('test', f), featureStr);
availableFeatures = featureStr(logical(index));

However, the above just confirms that the license exists, not that it can be checked out. The license could have expired or all the available licenses could be checked out by other users. To be absolutely certain that you will be able to use the available toolboxes, you can actually try to check out a license for the ones you need and test to see if you were successful. The following code attempts to check out a license for all the available toolboxes found above:

但是,上面的内容只是确认了许可证的存在,而不是检查它。许可证可能已经过期,或者其他用户可以检查所有可用的许可证。为了绝对确定您将能够使用可用的工具箱,您实际上可以尝试为您需要的工具签出许可证并进行测试,看看您是否成功。下面的代码尝试为上面找到的所有可用工具箱检查许可证:

index = cellfun(@(f) license('checkout', f), availableFeatures);
checkedOutFeatures = availableFeatures(logical(index));

WORD OF WARNING!:

警告!:

As Jason S mentions in a comment below, it's a bad idea to check out licenses willy-nilly, since they won't be released until you close MATLAB. You should only check out a license that you know you will need for a given application! Normally, licenses aren't checked out until you try to use a function from a given toolbox. For example:

正如Jason S在下面的一篇评论中提到的,不管愿不愿意都要检查许可证是一个糟糕的主意,因为在您关闭MATLAB之前,它们不会被释放。您应该只检查您知道您将需要一个给定应用程序的许可证!通常,直到您尝试使用来自给定工具箱的函数时,许可证才会被检出。例如:

>> license('inuse')
matlab
>> gaussFilter = fspecial('gaussian');  % An Image Processing Toolbox function
>> license('inuse')
image_toolbox
matlab

#2


11  

Ver seems like the way to go, and parsing shouldn't be that hard. Let's see:

Ver似乎是要走的路,解析不应该那么难。让我们来看看:

function tf = areTheseToolboxesInstalled(requiredToolboxes)
%ARETHESETOOLBOXESINSTALLED takes a cell array of toolbox names and checks whether they are currently installed
% SYNOPSIS tf = areTheseToolboxesInstalled(requiredToolboxes)
%
% INPUT requiredToolboxes: cell array with toolbox names to test for. Eg. 
%        {'MATLAB','Image Processing Toolbox'}
%
% OUTPUT tf: true or false if the required toolboxes are installed or not
%%%%%%%%%%%%%%%%%%%%%%%%%%

% get all installed toolbox names
v = ver;
% collect the names in a cell array
[installedToolboxes{1:length(v)}] = deal(v.Name);

% check 
tf = all(ismember(requiredToolboxes,installedToolboxes));

By the way, if you need to check for versions, verLessThan is your friend.

顺便说一下,如果你需要检查版本,verLessThan是你的朋友。

#3


7  

I know this is a pretty old question, but a really simple answer is actually in the question (parse the output of ver) ....

我知道这是一个非常古老的问题,但一个很简单的回答实际上是在问题(解析版本的输出)....

>> v = ver;
>> setdiff({v.Name}, 'MATLAB')'

ans = 

    'Aerospace Blockset'
    'Aerospace Toolbox'
    'Bioinformatics Toolbox'
    'Communications System Toolbox'
    'Computer Vision System Toolbox'
    'Control System Toolbox'
    'Conversion to SeDuMi'
    'Curve Fitting Toolbox'
    'DSP System Toolbox'
    'Database Toolbox'
    'Datafeed Toolbox'
    'Econometrics Toolbox'
    'Embedded Coder'
    'Financial Derivatives Toolbox'
    'Financial Toolbox'
    'Fixed-Income Toolbox'
    'Fixed-Point Toolbox'
    'Fuzzy Logic Toolbox'
    'Global Optimization Toolbox'
    'Image Acquisition Toolbox'
    'Image Processing Toolbox'
    'Instrument Control Toolbox'
    'MATLAB Coder'
    'MATLAB Distributed Computing Server'
    'MATLAB Report Generator'
    'Mapping Toolbox'
    'Model Predictive Control Toolbox'
    'Neural Network Toolbox'
    'Optimization Toolbox'
    'Parallel Computing Toolbox'
    'Partial Differential Equation Toolbox'
    'Phased Array System Toolbox'
    'RF Toolbox'
    'Robust Control Toolbox'
    'Signal Processing Toolbox'
    'SimBiology'
    'SimDriveline'
    'SimElectronics'
    'SimEvents'
    'SimHydraulics'
    'SimMechanics'
    'SimPowerSystems'
    'SimRF'
    'Simscape'
    'Simulink'
    'Simulink 3D Animation'
    'Simulink Coder'
    'Simulink Control Design'
    'Simulink Design Optimization'
    'Simulink Fixed Point'
    'Simulink Report Generator'
    'Simulink Verification and Validation'
    'Stateflow'
    'Statistical Graphics Toolbox'
    'Statistical Parametric Mapping'
    'Statistics Toolbox'
    'Symbolic Math Toolbox'
    'System Identification Toolbox'
    'SystemTest'
    'Wavelet Toolbox'

#4


3  

Simply typing ver would display the complete list of toolboxes installed in your matlab.

只需输入ver,就可以显示安装在matlab中的工具箱的完整列表。

#5


2  

a quick way is to list the contents of the toolboxes directory:

快捷方式是列出工具箱目录的内容:

l = ls( toolboxdir('') )

using that list (excluding a few directories: shared,local), you can find out the version installed of a toolbox using ver:

使用该列表(不包括几个目录:共享的、本地的),您可以使用ver找到工具箱安装的版本:

v = ver('nnet')

as a reference, here's a list of the toolboxes directory names I had:

作为参考,以下是我拥有的工具箱目录名列表:

bioinfo 
curvefit
database
gads    
ident   
images  
nnet    
optim   
pde     
signal  
stats   
wavelet 

#6


1  

A practical approach would be to start your code with a try somefunction catch statement, where somefunction is unique to the toolbox you need.

一个实用的方法是使用try somefunction catch语句开始代码,其中的somefunction是您需要的工具箱中惟一的。

The somefunction may fail for many reasons, for example that you lack available licenses or that the toolbox is not installed on your system. The try/catch allows you to abort gracefully and give the user a meaningful message as to exactly why it's not possible to perform the requested operation (right now).

somefunction可能会由于许多原因而失败,例如,您缺少可用的许可,或者工具箱没有安装在您的系统上。try/catch允许您优雅地中止,并向用户提供一个有意义的消息,说明为什么不可能执行请求的操作(现在)。

The downside is that that is a less generic method. It lacks elegance and it is sensitive to namespace errors. The upside is that it tests if somefunction actually works. If it is used wisely it should grab hold of shared licenses only when you actually need them.

缺点是这是一种不太通用的方法。它缺乏优雅性,并且对名称空间错误很敏感。好处是,它可以测试某个函数是否真的有效。如果使用得当,它应该只在您实际需要共享许可证时才获得共享许可证。

#1


26  

One drawback to the ver function is that it only tells you what's installed, not what has an available license. It's possible to have a toolbox installed and no license to use it (or all the available licenses could be checked out by other users). A better choice is the license function, which (as you pointed out) requires a unique "feature string" for each toolbox.

ver函数的一个缺点是它只告诉您安装了什么,而不告诉您有什么许可。安装一个工具箱并没有使用它的许可是可能的(或者其他用户可以检查所有可用的许可证)。一个更好的选择是许可函数,它(正如您指出的)要求每个工具箱都有一个惟一的“特性字符串”。

Here's an older list of feature strings for various toolboxes taken from a now-defunct newsgroup thread (link is now dead):

下面是一个旧的特性字符串列表,用于从一个现已失效的新闻组线程(link现在已经失效)中获取的各种工具箱:

featureStr = {'Aerospace_Blockset'; ...
              'Aerospace_Toolbox'; ...
              'Bioinformatics_Toolbox'; ...
              'Communication_Blocks'; ...
              'Communication_Toolbox'; ...
              'Compiler'; ...
              'Control_Toolbox'; ...
              'Curve_Fitting_Toolbox'; ...
              'Data_Acq_Toolbox'; ...
              'Database_Toolbox'; ...
              'Datafeed_Toolbox'; ...
              'Dial_and_Gauge_Blocks'; ...
              'Distrib_Computing_Toolbox'; ...
              'Econometrics_Toolbox'; ...
              'EDA_Simulator_Link_DS'; ...
              'Embedded_Target_c166'; ...
              'Embedded_Target_c2000'; ...
              'Embedded_Target_c6000'; ...
              'Embedded_Target_MPC555'; ...
              'Excel_Link'; ...
              'Filter_Design_HDL_Coder'; ...
              'Filter_Design_Toolbox'; ...
              'Fin_Derivatives_Toolbox'; ...
              'Financial_Toolbox'; ...
              'Fixed_Income_Toolbox'; ...
              'Fixed_Point_Toolbox'; ...
              'Fixed-Point_Blocks'; ...
              'Fuzzy_Toolbox'; ...
              'GADS_Toolbox'; ...
              'IDE_Link_MU'; ...
              'Identification_Toolbox'; ...
              'Image_Acquisition_Toolbox'; ...
              'Image_Toolbox'; ...
              'Instr_Control_Toolbox'; ...
              'Link_for_Incisive'; ...
              'Link_for_ModelSim'; ...
              'Link_for_Tasking'; ...
              'Link_for_VisualDSP'; ...
              'MAP_Toolbox'; ...
              'MATLAB'; ...
              'MATLAB_Builder_for_dot_Net'; ...
              'MATLAB_Builder_for_Java'; ...
              'MATLAB_Distrib_Comp_Engine'; ...
              'MATLAB_Excel_Builder'; ...
              'MATLAB_Link_for_CCS'; ...
              'MATLAB_Report_Gen'; ...
              'MBC_Toolbox'; ...
              'MPC_Toolbox'; ...
              'NCD_Toolbox'; ...
              'Neural_Network_Toolbox'; ...
              'OPC_Toolbox'; ...
              'Optimization_Toolbox'; ...
              'PDE_Toolbox'; ...
              'Power_System_Blocks'; ...
              'Real-Time_Win_Target'; ...
              'Real-Time_Workshop'; ...
              'RF_Blockset'; ...
              'RF_Toolbox'; ...
              'Robust_Toolbox'; ...
              'RTW_Embedded_Coder'; ...
              'Signal_Blocks'; ...
              'Signal_Toolbox'; ...
              'SimBiology'; ...
              'SimDriveline'; ...
              'SimElectronics'; ...
              'SimEvents'; ...
              'SimHydraulics'; ...
              'SimMechanics'; ...
              'Simscape'; ...
              'SIMULINK'; ...
              'Simulink_Control_Design'; ...
              'Simulink_Design_Verifier'; ...
              'Simulink_HDL_Coder'; ...
              'Simulink_Param_Estimation'; ...
              'SIMULINK_Report_Gen'; ...
              'SL_Verification_Validation'; ...
              'Spline_Toolbox'; ...
              'Stateflow'; ...
              'Stateflow_Coder'; ...
              'Statistics_Toolbox'; ...
              'Symbolic_Toolbox'; ...
              'SystemTest'; ...
              'Video_and_Image_Blockset'; ...
              'Virtual_Reality_Toolbox'; ...
              'Wavelet_Toolbox'; ...
              'XPC_Embedded_Option'; ...
              'XPC_Target'};

This covers many of the common ones, but isn't exhaustive and doesn't include feature strings for newer toolboxes. There doesn't appear to be any readily-available list of current feature strings for all MathWorks toolboxes. I believe you can find them on the "INCREMENT" lines in a license file, or (as vlee mentions in a comment) you can call a function from a given toolbox and then use license('inuse') to get the feature string from the displayed list of toolboxes currently being used. However, both of the above options require an available license already.

这涵盖了许多常见的功能,但并不详尽,也不包括新工具箱的特性字符串。对于所有MathWorks工具箱,似乎没有任何现成的当前特性字符串列表。我相信您可以在许可证文件的“增量”行中找到它们,或者(正如vlee在注释中提到的)您可以从给定的工具箱中调用一个函数,然后使用license('inuse')从当前使用的工具箱列表中获取特性字符串。但是,上述两个选项都需要一个可用的许可。

Using the above list of feature strings and the function license, you can check which toolboxes you have a license to use. The following code checks for licenses for the entire list above:

使用上面的特性字符串列表和函数许可,您可以检查您要使用哪个工具箱。下面的代码检查了上面整个列表的许可证:

index = cellfun(@(f) license('test', f), featureStr);
availableFeatures = featureStr(logical(index));

However, the above just confirms that the license exists, not that it can be checked out. The license could have expired or all the available licenses could be checked out by other users. To be absolutely certain that you will be able to use the available toolboxes, you can actually try to check out a license for the ones you need and test to see if you were successful. The following code attempts to check out a license for all the available toolboxes found above:

但是,上面的内容只是确认了许可证的存在,而不是检查它。许可证可能已经过期,或者其他用户可以检查所有可用的许可证。为了绝对确定您将能够使用可用的工具箱,您实际上可以尝试为您需要的工具签出许可证并进行测试,看看您是否成功。下面的代码尝试为上面找到的所有可用工具箱检查许可证:

index = cellfun(@(f) license('checkout', f), availableFeatures);
checkedOutFeatures = availableFeatures(logical(index));

WORD OF WARNING!:

警告!:

As Jason S mentions in a comment below, it's a bad idea to check out licenses willy-nilly, since they won't be released until you close MATLAB. You should only check out a license that you know you will need for a given application! Normally, licenses aren't checked out until you try to use a function from a given toolbox. For example:

正如Jason S在下面的一篇评论中提到的,不管愿不愿意都要检查许可证是一个糟糕的主意,因为在您关闭MATLAB之前,它们不会被释放。您应该只检查您知道您将需要一个给定应用程序的许可证!通常,直到您尝试使用来自给定工具箱的函数时,许可证才会被检出。例如:

>> license('inuse')
matlab
>> gaussFilter = fspecial('gaussian');  % An Image Processing Toolbox function
>> license('inuse')
image_toolbox
matlab

#2


11  

Ver seems like the way to go, and parsing shouldn't be that hard. Let's see:

Ver似乎是要走的路,解析不应该那么难。让我们来看看:

function tf = areTheseToolboxesInstalled(requiredToolboxes)
%ARETHESETOOLBOXESINSTALLED takes a cell array of toolbox names and checks whether they are currently installed
% SYNOPSIS tf = areTheseToolboxesInstalled(requiredToolboxes)
%
% INPUT requiredToolboxes: cell array with toolbox names to test for. Eg. 
%        {'MATLAB','Image Processing Toolbox'}
%
% OUTPUT tf: true or false if the required toolboxes are installed or not
%%%%%%%%%%%%%%%%%%%%%%%%%%

% get all installed toolbox names
v = ver;
% collect the names in a cell array
[installedToolboxes{1:length(v)}] = deal(v.Name);

% check 
tf = all(ismember(requiredToolboxes,installedToolboxes));

By the way, if you need to check for versions, verLessThan is your friend.

顺便说一下,如果你需要检查版本,verLessThan是你的朋友。

#3


7  

I know this is a pretty old question, but a really simple answer is actually in the question (parse the output of ver) ....

我知道这是一个非常古老的问题,但一个很简单的回答实际上是在问题(解析版本的输出)....

>> v = ver;
>> setdiff({v.Name}, 'MATLAB')'

ans = 

    'Aerospace Blockset'
    'Aerospace Toolbox'
    'Bioinformatics Toolbox'
    'Communications System Toolbox'
    'Computer Vision System Toolbox'
    'Control System Toolbox'
    'Conversion to SeDuMi'
    'Curve Fitting Toolbox'
    'DSP System Toolbox'
    'Database Toolbox'
    'Datafeed Toolbox'
    'Econometrics Toolbox'
    'Embedded Coder'
    'Financial Derivatives Toolbox'
    'Financial Toolbox'
    'Fixed-Income Toolbox'
    'Fixed-Point Toolbox'
    'Fuzzy Logic Toolbox'
    'Global Optimization Toolbox'
    'Image Acquisition Toolbox'
    'Image Processing Toolbox'
    'Instrument Control Toolbox'
    'MATLAB Coder'
    'MATLAB Distributed Computing Server'
    'MATLAB Report Generator'
    'Mapping Toolbox'
    'Model Predictive Control Toolbox'
    'Neural Network Toolbox'
    'Optimization Toolbox'
    'Parallel Computing Toolbox'
    'Partial Differential Equation Toolbox'
    'Phased Array System Toolbox'
    'RF Toolbox'
    'Robust Control Toolbox'
    'Signal Processing Toolbox'
    'SimBiology'
    'SimDriveline'
    'SimElectronics'
    'SimEvents'
    'SimHydraulics'
    'SimMechanics'
    'SimPowerSystems'
    'SimRF'
    'Simscape'
    'Simulink'
    'Simulink 3D Animation'
    'Simulink Coder'
    'Simulink Control Design'
    'Simulink Design Optimization'
    'Simulink Fixed Point'
    'Simulink Report Generator'
    'Simulink Verification and Validation'
    'Stateflow'
    'Statistical Graphics Toolbox'
    'Statistical Parametric Mapping'
    'Statistics Toolbox'
    'Symbolic Math Toolbox'
    'System Identification Toolbox'
    'SystemTest'
    'Wavelet Toolbox'

#4


3  

Simply typing ver would display the complete list of toolboxes installed in your matlab.

只需输入ver,就可以显示安装在matlab中的工具箱的完整列表。

#5


2  

a quick way is to list the contents of the toolboxes directory:

快捷方式是列出工具箱目录的内容:

l = ls( toolboxdir('') )

using that list (excluding a few directories: shared,local), you can find out the version installed of a toolbox using ver:

使用该列表(不包括几个目录:共享的、本地的),您可以使用ver找到工具箱安装的版本:

v = ver('nnet')

as a reference, here's a list of the toolboxes directory names I had:

作为参考,以下是我拥有的工具箱目录名列表:

bioinfo 
curvefit
database
gads    
ident   
images  
nnet    
optim   
pde     
signal  
stats   
wavelet 

#6


1  

A practical approach would be to start your code with a try somefunction catch statement, where somefunction is unique to the toolbox you need.

一个实用的方法是使用try somefunction catch语句开始代码,其中的somefunction是您需要的工具箱中惟一的。

The somefunction may fail for many reasons, for example that you lack available licenses or that the toolbox is not installed on your system. The try/catch allows you to abort gracefully and give the user a meaningful message as to exactly why it's not possible to perform the requested operation (right now).

somefunction可能会由于许多原因而失败,例如,您缺少可用的许可,或者工具箱没有安装在您的系统上。try/catch允许您优雅地中止,并向用户提供一个有意义的消息,说明为什么不可能执行请求的操作(现在)。

The downside is that that is a less generic method. It lacks elegance and it is sensitive to namespace errors. The upside is that it tests if somefunction actually works. If it is used wisely it should grab hold of shared licenses only when you actually need them.

缺点是这是一种不太通用的方法。它缺乏优雅性,并且对名称空间错误很敏感。好处是,它可以测试某个函数是否真的有效。如果使用得当,它应该只在您实际需要共享许可证时才获得共享许可证。