How to check if matlab toolbox installed in matlab - 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...

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)

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');

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

Here is a dirty solution:
try
<funktion from specific toolbox>
<do this if it is available>
catch
<do this if it is not
end

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.

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:
matlab.addons.installedAddons: Will list all installed add-ons with (long) Name, Version, Identifier (aka short name/hash)
matlab.addons.isAddonEnabled: To check if a given add-on is enabled

Related

How to make an executable file on matlab and run on raspberry pi 3B [duplicate]

I was wondering if there is a way to create a '.exe' file from ' .m' file in MATLAB, such that it can be run in machine which does not have MATLAB (like it can be done in C, C++).
I know writing a MATLAB function is one way, but I am not sure if it can run in machine without MATLAB.
Also I would like to hide my code and just create a script which can be run by a user using his own data files.
The Matlab Compiler is the standard way to do this. mcc is the command. The Matlab Runtime is required to run the programs; I'm not sure if it can be directly integrated with the executable or not.
If you have MATLAB Compiler installed, there's a GUI option for compiling. Try entering
deploytool
in the command line. Mathworks does a pretty good job documenting how to use it in this video tutorial: http://www.mathworks.com/products/demos/compiler/deploytool/index.html
Also, if you want to include user input such as choosing a file or directory, look into
uigetfile % or uigetdir if you need every file in a directory
for use in conjunction with
guide
Try:
mcc -m yourfile
Also see help mcc
If your code is more of a data analysis routine (vs. visualization / GUI), try GNU Octave. It's free and many of its functions are compatible with MATLAB. (Not 100% but maybe 99.5%.)
mcc -?
explains that the syntax to make *.exe (Standalone Application) with *.m is:
mcc -m <matlabFile.m>
For example:
mcc -m file.m
will create file.exe in the curent directory.
It used to be possible to compile Matlab to C with older versions of Matlab. Check out other tools that Matlab comes with.
Newest Matlab code can be exported as a Java's jar or a .Net Dll, etc. You can then write an executable against that library - it will be obfuscated by the way. The users will have to install a freely available Matlab Runtime.
Like others mentioned, mcc / mcc.exe is what you want to convert matlab code to C code.
The "StandAlone" method to compile .m file (or files) requires a set of Matlab published library (.dll) files on a target (non-Matlab) platform to allow execution of the compiler generated .exe.
Check MATLAB main site for their compiler products and their limitations.
I developed a non-matlab software for direct compilation of m-files (TMC Compiler). This is an open-source converter of m-files projects to C. The compiler produces the C code that may be linked with provided open-source run-time library to produce a stand-alone application. The library implements a set of build-in functions; the linear-algebra operations use LAPACK code. It is possible to expand the set of the build-in functions by custom implementation as described in the documentation.

Mex or Compile (mcc) Matlab function that uses toolkits

Environment:
Matlab R2012a (I have access to others if necessary)
All Toolboxes/Compiler installed
Ubuntu 12.04 64bit and/or Windows 7 64bit
I am working with the source for a software package written in Matlab (unfortunately its proprietary so no code examples...sorry), and one function briefly uses the Control System Toolbox and the Signal Processing Toolbox.
I have no problem running the code on my personal computer because I have every toolbox installed, however I would like to compile (mex or mcc) JUST the function using those two toolboxes. The goal, of course, is to run the software on a machine without those toolboxes, while leaving the remaining code open to change.
According to matlab, they have no problem with you compiling code that uses almost any toolbox. Here is the list of toolboxes that support mcc compilation:
http://www.mathworks.com/products/compiler/supported/compiler_support.html
The problem arises in that mcc no longer allows compiling with the -x option to create a mex-ed version of the function, so I'm forced to create a C executable (maybe? hopefully not). This particular function takes large matrices as parameters (impractical to write as a command line argument) and returns a structure of cell arrays.
The only way around this (as I see it now) would be to write the arguments (large matrices) to the hard drive in a binary .mat file , have the compiled C binary read in the arguments, run the algorithm, and finally save the return values in another .mat for the parent thread to load back into memory.
This seems totally impractical. I would greatly appreciate alternative suggestions. Please let me know if anything here in unclear. Thanks in advance!
[Edit 1] The codegen package does not support tf.m. It seems like this should be possible (and used to be possible with the mex -x option), but I'm at a loss. Any suggestions would be greatly appreciated!
I think the reason -x is not supported anymore is the fact that Matlab now has a product called "coder", which converts .m files to .c files and can also create .mex files from "suitable" .m files using the option -args to specify the input arguments: http://www.mathworks.com/videos/generating-c-code-from-matlab-code-68964.html

Which values are allowed for environment variable MAKE_MODE when using GNU make?

I usually have an environment setting for MAKE_MODE (Windows XP, using GNU make, both under Cygwin and native)
set MAKE_MODE=UNIX
I now found differences between my build server (which has no MAKE_MODE defined) and a local build. This may be something completely different, but it got me wondering what other values I could specify for MAKE_MODE.
I think I know that MAKE_MODE=UNIX is suppose to tell GNU make to use /bin/sh - if it finds it - , but I quickly checked the GNU make manual and couldn't find a description. A google search only told me what I already know, but doesn't give a valid alternative.
Is the only alternative to not define the variable? Does it have influence at all when using CMD.exe and a native version of GNU make?
EDIT: So far I have found references for the values 'unix', 'win32', 'null' and undefined, but no explanations, and no specifications. But a look at the source code for GNU make 3.82 shows not a single occurrence of the string "MAKE_MODE", so GNUmake itself apparently doesn't change its behavior when this environment variable is set or not.
EDIT2: I checked the source code for GNU make for MinGW, and again found nothing. Maybe it's CygWin specific?
EDIT3: I found a reference that it might be property of an old version of GNU make, so I checked version 3.75. No luck, the string MAKE_MODE does not appear in the source code at all. The next step really must be the Cygwin version of GNU make. I know from 10 years ago that the Cygwin port in those days was not integrated in the regular source tree.
I found an ancient mailing list entry on the Cygwin site, explaining the basic operational effect of MAKE_MODE. This definitely indicates that the variable has to do with the Cygwin implementation of GNU make.
I'll dig around in the source code, and add to this answer when I find more details.
UPDATE: In a more recent post by maintainer Christopher Faylor I found the following update for GNU make version 3.81:
Note that the --win32 command line option and "MAKE_MODE" environment
variable are no longer supported in Cygwin's make. If you need to use a
Makefile which contains MS-DOS path names, then please use a MinGW
version of make.
I've not really found the values allowed for MAKE_MODE, but it's not any more necessary or supported in most recent versions of GNU make for Cygwin, and it was used for supporting DOS filenames in Cygwin's make.
And if you really want to know the set of allowed values, look in the source for Cygwin's make version before 3.81-1. I guess the only useful value was unix, all others will have meant the same.
Case closed? There's still not many views here...

Non-windows way to invoke Matlab from Mathematica

This was asked before, but the solution doesn't seem to work on MacOS. Wolfram Library has a package for 7 year old Matlab version. Is there a solution that works on MacOS 10.6 and Matlab 7.9?
I want to call CVX from Mathematica
You could use RunThrough["command",expr], this runs the external command command, and feeds expr (a Mathematica expression) as input to command
An example of a suitable command would be "matlab -r \"matlab expr\"", you could place your CVX specific code in the "matlab expr" string.
Update: Right now, probably MATLink is the best way to do this. It works on Windows/Linux/Mac.
Disclosure: I'm one of MATLink's authors.
Have you tried using the newer mEngine instead? I can only try it on Windows, but after looking at the sources, I believe it might work on other platforms too.
Hopefully you only need to modify main.c, actually just copy and paste the main function from one of the MathLink examples (e.g. addtwo), as mEngine's main.c has the non-Windows-specific part removed. Then compile the package as a MathLink program.

Running on 32 or 64 bit matlab?

How can I determine if I'm running on a 32bit or a 64bit version of matlab?
I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab.
The question of 32 vs. 64 bits is really a red herring. If I understand correctly, you want to determine which set of compiled MEX files are needed so you can set the path appropriately. For this, you can use the function mexext:
>> help mexext
MEXEXT MEX filename extension for this platform, or all platforms.
EXT = MEXEXT returns the MEX-file name extension for the current
platform.
ALLEXT = MEXEXT('all') returns a struct with fields 'arch' and 'ext'
describing MEX-file name extensions for all platforms.
There is a script named mexext.bat on Windows and mexext.sh on UNIX
that is intended to be used outside MATLAB in makefiles or scripts. Use
that script instead of explicitly specifying the MEX-file extension in
a makefile or script. The script is located in $MATLAB\bin.
See also MEX, MEXDEBUG.
Taking up on ScottieT812 and dwj suggestions, I post my own solution to earn some points.
The function computer returns the architecture I'm running on. so:
switch computer
case 'GLNX86'
display('32-bit stuff')
case 'GLNXA64'
display('64-bit stuff')
otherwise
display('Not supported')
end
works for me
Does this really work? Which version of matlab are you using?
As far as I'm aware the 64 bit platforms end with "64" not 86. From the matlab site
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/computer.html I don't think that computer will ever return GLNXA86 but GLNXA64 instead.
So this question is specific to GNU Linux 32bit or 64bit version.
If you are testing for any 64bit platform then you probably need to test the last 2 characters to find "64" i.e. something like
if regexp(computer,'..$','match','64'),
% setup 64bit options
else,
% 32bit options
end