MATLAB Integration

Integration Using MATLAB: Exploring General Information, Initializing the MATLAB Server, and Testing the MATLAB Connection in Innoslate's MATLAB Toolkit Integration

Sections Available in MATLAB Integration

Function Description
General Information Learn an overview of the MATLAB Toolkit Integration in Innoslate, understanding the commands of integration with the platform.
Initializing MATLAB Server Learn how to initialize the MATLAB Server within Innoslate, establishing a connection between the two platforms for data exchange and collaboration.
Add Environment Variables Add Environment Variables in the OS for integration. 
Testing MATLAB Connection Learn the steps to test the connection between Innoslate and MATLAB integration toolkit, ensuring a reliable and stable connection.

General Information

For the integration of MATLAB/Simulink and Innoslate, a Java Web Application (JWA) software tool was developed. The JWA tool creates the interface between the two software systems. The JWA tool can be installed on any server, may be packaged in the same installation package as Innoslate, and runs out of the same browser that Innoslate does. The JWA processes data requests from Innoslate and integrates these requests into a MATLAB Environment.

JWA needs to be placed in the C:\Innoslate\apache-tomcat\webapps folder. Then the following environment variables are needed to be added to the Path:

  • C:\Program Files\MATLAB\R2020b\bin
  • C:\Program Files\MATLAB\R2020b\bin\win64

Note the version of MATLAB will differ based on what version of MATLAB that is installed on the system.

Updating MATLAB engine.jar file in JWA:

In the lib folder of the JWA there is an engine.jar file. This file is specific to the version of MATLAB that you have installed. The default version is R2020b. This file version will need to match your MATLAB version. After copying over the engine.jar file, Innoslate will need to be restarted.

Lib file path:

  • C:\Innoslate4\apache-tomcat\webapps\integrations\WEB-INF\lib

Engine.jar file path for MATLAB:

  • C:\Program Files\MATLAB\R2020b\extern\engines\java\jar

Note the path of MATLAB will differ based on what version of MATLAB that is installed on the system.

Simulator MATLAB JWA URL:

In the simulator in the settings tab there is a field where you can add the MATLAB JWA URL.

Ex: http://localhost:8080/integrations/MatlabServlet

JAVASCRIPTS Commands:

get: function (parameter, evaluation, filePath)

post: function (parameter, evaluation, filePath)
  • parameter: this variable represents a variable within the MATLAB Environment; it is able to have or not have a value associated with it.
  • evaluation: this variable is obtained from a request sent to the JWA. It represents an evaluation to evaluate within MATLAB Environment.
  • filePath: this variable is a file path or directory. The variable is obtained from a request sent to JWA.

In the simulator script to access the MATLAB function used the MATLAB variable:

Ex: x = MATLAB.get(“x”);

Ex: MATLAB.post(null, “x + y”, null);

File Path Example:

The file path is location to where scripts is located

The name of the script is test.m with a function of test(x) in the script.

 

1. Post Request:

Evaluate function without saving results to parameter:

var x =MATLAB.post(null, test(5), “C:\Users\John\Documents”);

To Evaluate function and save to a parameter:

MATLAB.post(“y”, test(5), “C:\Users\John\Documents”);

 

2. Get Request:

Evaluate function without saving results to parameter:

var x = MATLAB.get(null, test(8), “C:\Users\John\Documents”);

To Evaluate function and save to a parameter:

MATLAB.get(“y”, test(8), “C:\Users\John\Documents”);

Initializing MATLAB Server

1. Click on the Windows icon at the left hand corner of the desktop.


2. Select the Settings and go to Accounts

matlab integration 2

3. Click on Other Users

4. Click Add someone else to this PC

5. Another way to access “lusrmgr” window

    1. Enter lusrmgr.msc in the search bar
    2. Click on the lusrmgr.msc

matlab integration 5

6. On the lusrmgr.msc window select Users

matlab integration 6

7. Right Click on desired Users and click on Properties
    1. The User (John Doe) will be the one to run start up Innoslate 

8. Click on tab Member Of

9. Make sure that the User is member of Users and Administration

matlab integration 9

    1. If User is not members of both then exit screen and click on Groups
    2. Under Groups right click Users and select Propertiesmatlab integration 9b
    3. Click the Add… button
      matlab integration 9c
    4. Enter User’s name into box
      matlab integration 9d
    5. Click on Check Names
    6. After clicking Check Names the name should change to the following
    7. Disclosure: the label in front of the User is the name of server

matlab integration 9g

10. Apply all changes and exit. Go to Windows and search for Services.

11. In Services, stop Innoslate from running by right clicking on Innoslate and select Stop

12. Right Click on Innoslate and select Properties

matlab integration 12

13. Click on Log On tab

matlab integration  13

14. Click on circle next to This account and then click Browse
    1. Disclosure: Erase the Original Password and use the Login Password of the User instead

matlab integration 14a

15. On the same window, click Apply then OK

16. Start Innoslate

Add Environment Variables 

A total of three environment variables are needed to ensure the integration will work.

  1. Navigate to ‘Control Panel > System and Security > System’ and click on ‘Advanced System Settings’ on the left.
  2. matlab env 1Click on ‘Environmental Variables’ button at the bottom of pop-up.

matlab env 23. Under ‘System Variables’ press ‘New…’ and for variable name input. ‘CATALINA_HOME_MATLAB’ and for variable value input the path to file located within Innolsate4 at: ‘Innoslate4\apache-tomcat-matlab’.

4. Under the ‘Systems Variables’ click on Variable ‘Path’ then press the ‘Edit’ button.
matlab env 35. Ensure that both of the following are listed, add if necessary by pressing ’New’ button on the right side and adding the path:
i. {Matlab Root Directory}/R2018a/bin
ii. {Matlab Root Directory}/R2018a/bin/win64

Notes: 

If users would like to make any changes to any files please keep the following in mind that the following must be different for the tomcat-matlab than the tomcat-innoslate:
a. The Server port (http/1.1) line # 22
b. Main connecting port line # 69
i. Innoslate’s: 8080
ii. MATLAB’s: 7777
c. AJP connecting port line # 120

Testing MATLAB Connection

1. Ensure the MATLAB Account and User are similar

    1. Check MATLAB account to ensure the proper User is login

2. Go to URL set up for Innoslate(http://localhost:8080/) and check the homepage appears

3. In separate tab, go to URL: http://localhost:8080/integrations/

testing matlab 3

4. On the page right click and select Inspect


5. A window will appear on the top left, click on the Console tab

6. Going to insert a simple math Problem for both POST Request And GET Request
    1. GET Request in the Evaluation type “ 4+4” and press GET button
    2. POST Request in the Evaluation type “ 4+4” and press Post button

7. Under File Path field there should be message that appears “Output  ans =8”


8. On the console window there should have the message that appears to be “ans = 8”

9. If an error message pops up instead of the “8” please get a message from the error message and send it back to SPEC Innovations.

To continue learning about Enterprise User Guides, Click Here.

(Next Article: STK API Integration)