Why do I need a license for functions I wrote?

I recently upgraded to R2017b. I have functions that I wrote myself and reside in a sub-directory of my Matlab work directory. The sub-dir is in my path and Matlab can see the functions via 'which', but it states that there is no license for that function. Why do I need a license for my own function?

Answers (1)

This can happen if you accidentally named the directory with the same name as one of the directories used to hold toolbox functions.
For example, MATLAB stores its Statistics And Machine Learning mnrnd in fullfile(matlabroot, 'toolbox', 'stats', 'stats', 'mnrnd.m') and it can get confused about the licensing required for your files if you happened to store them in a directory named stats

8 Comments

Thanks for the quick reply. I tried changing the name of my sub-directory (now called 'scottsFunctions') but I still get the same issue. Any other ideas? Thanks!
What are the directory names above that?
Give 3 names of functions for which it says you have no license, as an example. Of course you can always call the tech support installation hotline for the fastest installation help.
My working directory is C:\Users\sdiamond\Documents\MATLAB. The subdir that is giving me issues is C:\Users\sdiamond\Documents\MATLAB\scottsFunctions.
The files calc_slantrange.m, confine0to360.m, compute_SunEl.m and computeSiderialTime.m all give me the error. I moved computeSiderialTime.m up one level and did NOT get the license error.
Can you copy and paste the EXACT error message you are seeing so we don't have to guess?
What was the previous directory name? Have you happened to restart MATLAB after you renamed the directory? That could fix the problem. Or use "clear" with the names of the functions might fix the problem.
I have restarted Matlab and still have this problem. Here is an example with the function 'confine0to360'
>> which confine0to360
C:\Users\sdiamond\Documents\MATLAB\scottFun\confine0to360.m % Has no license available
>> help confine0to360
confine0to360 is a function.
outAngle = confine0to360(inAngle)
>> angle = confine0to360(450)
Undefined function 'confine0to360' for input arguments of type 'double'.
if I move this function up one level to C:\Users\sdiamond\Documents\MATLAB, it will work.
Do you have any .lic files in your search path? Have you read the help on licenses:
Understanding License Files
License File Description License File Search Path License File Description A License File is a specially formatted ASCII text file that contains encrypted product passcodes for each product you are licensed to run. Each product passcode identifies the number of keys available for that product. The license manager grants or denies access to a product depending on the availability of the license keys associated with each product.
The following figure presents a sample License File. Each INCREMENT line identifies a product, the number of keys available for the product, and other information. (The INCREMENT lines in your License File might not include every element shown in the example.) The backslash (\) character indicates that the line continues onto the next line.
The lines that begin with a pound sign (#) are comments. The MathWorks Installer uses the information in these comment lines (license server host ID or Internet address) when it processes the License File during installation.
  1. BEGIN-------cut here-------CUT HERE-------BEGIN
  2. MATLAB license passcode file.
  3. LicenseNo: 12345 HostID: INTERNET=144.212.101.43INCREMENT TMW_Archive MLM 18 01-sep-2015 0 \ BC9DE773A77D15AF8 VENDOR_STRING=83 HOSTID=DEMO SN=12345INCREMENT MATLAB MLM 18 01-sep-2015 1 \ 4C9D3348561BE9E3B USER_BASED DUP_GROUP=U SN=12345INCREMENT SIMULINK MLM 18 01-sep-2015 1 \ 1CD148466EF58DF8B USER_BASED DUP_GROUP=U SN=12345INCREMENT Signal_Toolbox MLM 18 01-sep-2015 1 \ 6CF74B458BA143DC3 USER_BASED DUP_GROUP=U SN=12345
  4. END---------cut here-------CUT HERE-------ENDLicense File Search PathWhen you start MATLAB®, it reads the License File to check for product licensing. MATLAB searches for the License file in the following locations, in the specified order. After it finds a License File, MATLAB stops searching.
License File specified on MATLAB startup command line using the -c option. You can specify a list of paths to search. When you use the -c option, you explicitly prohibit the searching of the environment variables. When using the -c option, keep in mind the following: If the path to your License File contains a space, enclose the path name in quotation marks. If you are specifying more than one License File, make sure to enclose the entire list of License Files in quotation marks. If no License File is specified at the MATLAB command line, MATLAB searches two environment variables, described in the following table. MATLAB searches the vendor-specific environment variable, MLM_LICENSE_FILE first. Environment Variable Purpose MLM_LICENSE_FILE Specifies the location of the License File, but only for MathWorks® products. (Recommended, because it affects only MathWorks products.) LM_LICENSE_FILE Specifies the location of the License File for all applications using FlexNet® licensing on this server. If it does not find any License File specified using environment variables, MATLAB searches the profile folder of the person starting the program. For licenses that are locked to individual users, the activation application puts the License File in a folder in your user profile. If it does not find any License File specified in environment variables or in your user profile, MATLAB checks the \licenses folder in your MATLAB installation for files named license.dat or any file with the extension .lic.

Sign in to comment.

Categories

Asked:

on 26 Dec 2017

Commented:

on 28 Dec 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!