Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Why can't I initialize the MATLAB Engine in MATLAB 7.7 (R2008b)?

Asked by MathWorks Support Team on 27 Jun 2009

When I execute the following in my C/C++ code, I get a NULL pointer as a result:

ep = engOpen("\0");

When I run the function GETMATLABDEFAULTSERVER from the solution 1-6JHG55, I get the following output:

 The default MATLAB Automation Server on this machine is:
 ProgId: Matlab.Application (Version 7.7)
 LocalServer32: C:\MATLAB\R2008b\bin\win32\MATLAB.exe /MLAutomation
 CLSID: {3A579EB9-8A43-4022-A1AF-4C13DDEC4079}
 File exists: 'C:\MATLAB\R2008b\bin\win32\MATLAB.exe'

So MATLAB seems to be registered correctly as an automation server. What could be the problem?

0 Comments

MathWorks Support Team

Products

1 Answer

Answer by MathWorks Support Team on 27 Jun 2009
Accepted answer

The function GETMATLABDEFAULTSERVER checks the following registry key, which specifies the default MATLAB automation server:

HKEY_CLASSES_ROOT\Matlab.Application

For the MATLAB Engine to work, there are additional keys that need to be registered correctly. In order to achieve this, you will need to run the following command from the MATLAB version that you want to use:

!matlab -regserver

This command needs to be called with administrator privileges, so that MATLAB can write the appropriate information to the Windows Registry.

MATLAB R2008a and higher requires activation. If you have a "Named User" license, and your administrator needs to login with a different username in order to run MATLAB with the required privileges, MATLAB will not start. To work around this issue, you will need to perform a second activation for the administrator on the same machine. You can do this automatically through the Internet or through the License Center.

0 Comments

MathWorks Support Team

Contact us