sam
sam

Reputation: 171

How to check if matlab toolbox installed in matlab

I am working on Matlab R2011a student edition. I want to run some demos provided in Matlab which require some toolbox like Embedded Coder and EDA Simulator Link.

I want to check if those toolboxes are installed in my current version of matlab and if yes how can I check if the licenses are valid.

The reference to this link didn't help me: How would one check for installed MATLAB toolboxes in a script/function? because I need at least the short name of those toolboxes like "control" states for "Control System Toolbox" by using the command ver control.

Any suggestion...

Upvotes: 17

Views: 50990

Answers (7)

deftclaw
deftclaw

Reputation: 66

I know it's been 12 years, but I get asked which systems have which toolboxes by end-users all of the time.

Our firm has ~ 20 machines in the office which engineers remote into from home, or even just the office to make good use of the licenses we have. We have an in-house tool which will displays which machines are in-use so that they do not interrupt each-others number-crunching.

For a similar reason, I needed to be able to list toolboxes without opening matlab (and therefor usurping the in-use license). Special thanks to @Matt for his answer I was able to write this Powershell function for querying remote servers (via admin $ share)

function Get-MatlabToolboxes($Machine) {
  [PSCustomObject]$lic_files = @{}
  [System.collections.arraylist]$licenses = @()
  $versions = ( Get-ChildItem "\\$Machine\c$\Program Files\MATLAB\R*" ).FullName

  # Collect all License files for each version
  foreach ($v in $versions) {
    # "Found Version: $v"
    [void]$licenses.add($((Get-ChildItem "$v\licenses").FullName))
  }

  # Read each license file into the key of it's filepath
  foreach ($l in $licenses) {
    # "Found License Path: $l"
    $lic_files["$l"] = $( Get-Content -raw "$l"|findstr 'INCREMENT' )
  }
  
  $Machine  # Report Which machine is being queried
  # List the toolboxes on this machine (cleanup output)
  $lic_files.values|ForEach-Object {
    "$_" -replace 'INCREMENT ','' `
         -replace ' \\',"`r`n" `
         -replace ' 01-jan-0000 uncounted',''
  }
}

I was able to create a list of hosts which have matlab installed on them and call this in a simple foreach loop and update documentation without interrupting any running MatLab sessions.

$ml_machines=('Matlab1', 'Matlab2', 'Matlab3')
$ml_machines|%{ Get-MatlabToolboxes -Machine "$_" }

Upvotes: 1

djm
djm

Reputation: 103

Just in case somebody stumbles upon this in 2022. There are now several built-in add-on utilities to check if add-ons are installed. Notably:

Upvotes: 2

NKN
NKN

Reputation: 6424

easily use ver command. it will list all installed toolboxes and their versions. the other way is to check from the start button.

Also you can use the existing function in FileExchange called isToolboxAvailable. The usage is as follows:

result = isToolboxAvailable('image processing toolbox','error');

Upvotes: 4

user4615063
user4615063

Reputation: 41

Here is a dirty solution:

try
    <funktion from specific toolbox>
    <do this if it is available>
catch
    <do this if it is not
end

Upvotes: 4

Matt
Matt

Reputation: 2379

The names of the toolboxes that are returned by the license function are the same as what is in the license file. The license file will either be on the local PC or on a FLEXlm license server, depending on your environment. On Windows, check in C:\Program Files\MATLAB\R2011a\licenses for a license file, which is typically named something like license.lic or network.lic. Open the file in your favorite editor (notepad will do). If you see text that says SERVER followed by a hostname, MAC address, and port number, then you're using a network license and you'll have to ask your systems administrator. Otherwise, there should be an INCREMENT line for each licensed product and the name of the product as used by the license function is given following the INCREMENT keyword. If you're on a UNIX or Linux system, you may have to dig around a bit to find the path for the license file (or perhaps someone else can provide this?).

Edit: My MATLAB install is in a non-standard path. Changed instructions to give the default path.

Upvotes: 2

Richie Cotton
Richie Cotton

Reputation: 121077

To check that the toolbox is installed, use

v = ver;
any(strcmp(toolboxName, {v.Name}))

where toolboxName is the name of the toolbox you want to check.

To check that the licence is valid, use

license('test', toolboxName)

Upvotes: 13

Rasman
Rasman

Reputation: 5359

you can always check out the main help documentation which generally lists the toolbox. Or if you press "Start" (the Matlab start, not Windows) the list of installed toolboxes will be organised by category

Upvotes: 3

Related Questions