OpenSim 4.0 and 3.3 with MATLAB R2018b Don't Work

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Stephanie Hachem
Posts: 34
Joined: Wed Oct 26, 2016 12:40 pm

OpenSim 4.0 and 3.3 with MATLAB R2018b Don't Work

Post by Stephanie Hachem » Wed Dec 26, 2018 1:25 pm

Hi,

I haven't seen anyone else report this error, but for me, neither MATLAB R2018b with OpenSim 4.0 nor MATLAB R2018b with OpenSim 3.3 works on Windows 10. I've been using OpenSim 3.3 with MATLAB R2017b for a while, which has worked fine, but recently my institution has received a license for MATLAB R2018b, just as the license for MATLAB R2017b has run out. So now I only have access to MATLAB R2018b, but it doesn't seem to work with OpenSim at all: with OpenSim 3.3, if I try to run configureOpenSim.m [someDirectory\OpenSim 3.3\Scripts\Matlab\configureOpenSim.m], I get an error with fprintf ('Error with fprintf \ Invalid file identifier. Use fopen to generate a valid file identifier.', also see the attached OpenSim3.3_MATLAB2018_configureOpenSim.png) If I debug, I can see this is because the file ID for opening 'C:\Program Files\MATLAB\R2018b\toolbox\local\classpath.txt' is -1, from the line 'fileID = fopen(txtname,'w');'. If I attempt 'fileID = fopen(txtname,'r');', to open the same file with read permissions, the fileID becomes 3, which means the file was successfully opened. The fopen merely doesn't work for writing. I get the same result (fileID = -1) whether I open as a non-admin user logged into a non-admin account, or as an admin logged into a non-admin account, or as an admin logged into an admin account.

As for using MATLAB R2018b with OpenSim 4.0, I found the configureOpenSim.m in OpenSim 4.0 (the main one, at the top of the OpenSim Downloads page on SimTK <https://simtk.org/frs/?group_id=91>). I opened MATLAB R2018b as admin in a non-admin account and ran that configureOpenSim.m, and I'm pretty sure that it reported that 'Paths have been successfully updated for the OpenSim API ' [something I don't remember] 'installed at ' [something I don't remember], or something along the lines of 'Path successfully updated'. I know that it reported that 'To complete setup, restart MATLAB. To test your set up, type: `model = org.opensim.modeling.Model();'. So I restarted MATLAB, but upon starting MATLAB MATLAB threw the following error (also see the attached OpenSim4.0_MATLAB2018_configureOpenSim.png):

Code: Select all

An error occurred while trying to determine whether "pathdef" is a function
name.
 
Undefined function 'usejava' for input arguments of type 'char'.
Warning: MATLAB did not appear to successfully set the search path. To recover
for this session of MATLAB, type "restoredefaultpath;matlabrc". To find out how
to avoid this warning the next time you start MATLAB, type "docsearch problem
path" after recovering for this session. 

	Primary and Secondary School License -- for use in teaching and
	meeting course requirements at primary and secondary schools only.

Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should
be resolved as soon as possible.  Error detected was:
MATLAB:UndefinedFunction
Undefined function 'usejava' for input arguments of type 'char'. 
> In matlabrc (line 66) 
Warning: Initializing MATLAB Graphics failed.
This indicates a potentially serious problem in your MATLAB setup, which should
be resolved as soon as possible.  Error detected was:
MATLAB:UndefinedFunction
Undefined function or variable 'ismac'. 
> In hgrc (line 163)
  In matlabrc (line 72) 
Warning: Failed to add default profiler filters. 
> In matlabrc (line 81) 
Undefined function or variable 'rmiml.getAll'.
 
Undefined function or variable 'rmiml.visibleInToolstrip'.
 
Undefined function or variable
'internal.matlab.desktop.editor.getSystemObjectInfo'.
 
Undefined function or variable
'matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip'.
 
Undefined function or variable 'rmiml.getAll'.
 
Undefined function or variable
'matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip'.
 
Undefined function or variable
'internal.matlab.desktop.editor.getSystemObjectInfo'.
 
Undefined function or variable 'rmiml.visibleInToolstrip'.
 
Undefined function or variable 'rmiml.getAll'.
 
Undefined function or variable
'matlab.unittest.internal.ui.toolstrip.getFileInfoForToolstrip'.
 
Undefined function or variable
'internal.matlab.desktop.editor.getSystemObjectInfo'.
 
Undefined function or variable 'rmiml.visibleInToolstrip'.
 
Undefined function or variable 'rmiml.visibleInToolstrip'.
 
Undefined function or variable 'connector.ensureServiceOn'.
 
Undefined function or variable 'connector.ensureServiceOn'.
 
Undefined function or variable 'connector.ensureServiceOn'.
 
Undefined function or variable 'connector.ensureServiceOn'.
 
com.mathworks.installservicehandler.exception.InstallServiceHandlerInternalException: An internal exception occurred inside the install service handler mechanism
	at com.mathworks.matlab_login.MatlabLogin.initializeLoginServices(Unknown Source)
	at com.mathworks.toolbox.distcomp.mwlogin.MatlabLoginController.<clinit>(MatlabLoginController.java:43)
	at com.mathworks.toolbox.distcomp.ui.desk.ClusterProfilesMenu$2.run(ClusterProfilesMenu.java:160)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.mathworks.mvm.exec.MvmExecutionException: connector.ensureServiceOn
	at com.mathworks.mvm.exec.NativeFutureResult.nativeGet(Native Method)
	at com.mathworks.mvm.exec.NativeFutureResult.get(NativeFutureResult.java:62)
	at com.mathworks.mvm.exec.FutureResult.getInternal(FutureResult.java:404)
	at com.mathworks.mvm.exec.FutureFevalResult.getInternal(FutureFevalResult.java:49)
	at com.mathworks.mvm.exec.FutureResult.get(FutureResult.java:262)
	at com.mathworks.matlabserver.connector.impl.ConnectorImpl.doEnsureServiceOn(ConnectorImpl.java:211)
	at com.mathworks.matlabserver.connector.api.Connector.ensureServiceOn(Connector.java:133)
	... 8 more
Undefined function or variable 'matlab.supportpackagemanagement.internal.getInstalledSupportPackagesInfo'.
 
Undefined function or variable 'mls.internal.FevalService.init'.
 
java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.services.editordataservice.EditorDataServiceManager$SingletonHolder
	at com.mathworks.services.editordataservice.EditorDataServiceManager.getInstance(EditorDataServiceManager.java:118)
	at com.mathworks.connector.standalone_host.impl.StandaloneHostImpl.startEditor(StandaloneHostImpl.java:244)
	at com.mathworks.connector.standalone_host.impl.StandaloneHostImpl.doStart(StandaloneHostImpl.java:101)
	at com.mathworks.connector.standalone_host.StandaloneHost.start(StandaloneHost.java:60)
Undefined function or variable 'connector.internal.lifecycle.callConnectorStarted'.
Several pop-up boxes stating 'Error using eval / Undefined function 'workspacefunc' for input arguments of type 'struct'.' also appear, and I click out of all of them, and then type 'restoredefaultpath;matlabrc' as suggested by the MATLAB error thrown. The MATLAB session works fine thereafter, but if I try to use OpenSim, it doesn't work (see the attached OpenSim4.0_MATLAB2018_doesntWork.png). I can see from forum posts that others have gotten OpenSim4.0 to work with MATLAB, but I'm not sure if they were using MATLAB R2018b. Anyways, any help would be appreciated!

Thank you!

Stephanie

Tags:

User avatar
Stephanie Hachem
Posts: 34
Joined: Wed Oct 26, 2016 12:40 pm

Re: OpenSim 4.0 and 3.3 with MATLAB R2018b Don't Work

Post by Stephanie Hachem » Fri Dec 28, 2018 9:37 pm

Hi,

I found a workaround:

If you've run the OpenSim 4.0 configureOpenSim.m file before, which affects the MATLAB path and makes the error posted about in the code block pop up each time you open a new session (window) of MATLAB, then open a new session of MATLAB (it should beep several times as you open the session, since the error posted above is being thrown) and run the command recommended in the error posted above: 'restoredefaultpath;matlabrc'.
If you haven't run that file and don't have that error, then just open a new session of MATLAB.

With a new session, open Windows environmental variables (search 'environment' in Windows settings, which opens a 'System Properties' window to the 'Advanced' tab. Here, click on 'Environment Variables', and a window called 'Environment Variables' should appear with two smaller windows inside, one titled 'User Variables for SOMEUSER' and another titled 'System Variables'. Here, in both the User Variables and the System Variables, change any mentions of 'OpenSim 3.3' to 'OpenSim 4.0'. For me, I changed 'OPENSIM_HOME' under User Variables, and 'OPENSIM_HOME' and 'Path' under System Variables. Then, close all windows of MATLAB and open a new window. (For me, at this point, the above posted error is no longer thrown upon MATLAB startup.) For me, this got the MATLAB-OpenSim interface working for MATLAB R2018b and OpenSim 4.0.

Hope this was helpful,

Stephanie

POST REPLY