Matlab2017a prints results of supressed API functions

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Pavlos Silvestros
Posts: 43
Joined: Sun Oct 16, 2016 4:10 am

Matlab2017a prints results of supressed API functions

Post by Pavlos Silvestros » Thu Sep 21, 2017 12:21 am

Dear all,

I have recently changed to a new PC that has Matlab2017a and OpenSim 3.3 (both 64-bit) from my old one Matlab2014a and OpenSim 3.3 (64-bit again). I am running pretty much the identical code but now some of the API commands are outputing their results to the command Window. I can't figure out why this is happening, I have gone through the code and checked for (;) after the commands that prints results and it seems ok.

The commands that output to the command window are:

Model();
My code:

Code: Select all

model=Model(modelFile);
Command Window output:
Loaded model RugbyModel_inertia_mass_mod from file C:\Users\ps605\Documents\PhD\OpenSim\C7C2_OPTIM.osim
PointKinematics.setBody() and PointKinematics.setRelativeToBody();
My code:

Code: Select all

pkC2=PointKinematics(model);
pkC2.setBody(c2Body);
pkC2.setRelativeToBody(groundBody);
Command Window output:
PointKinematics.setBody: set body to cerv2
PointKinematics.setRelativeToBody: set relative-to body to cerv2
and ForwardTool.run();
My code:

Code: Select all

fdTool.run();
Command Window output:
Usual FD tool output, state numbers, printing ect.

I am using these within an optimisation procedure that runs the script many times so I don't want it to keep writing the results as it may damage performance and its annoying.

If anyone has any suggestions I would greatly appreciate them!

Best regards,
Pavlos

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab2017a prints results of supressed API functions

Post by Christopher Dembia » Thu Sep 21, 2017 12:44 am

Hi Pavlos. This is not an issue with semicolons. For example, if you had a function that internally contained `disp('hello');`, that message would still be printed even if you terminated your function call with a semicolon. That's more of what the situation is here.

Whether or not OpenSim's print statements end up in the MATLAB Command Window depends on whether MATLAB and OpenSim use the same compiler version. See https://github.com/opensim-org/opensim-core/issues/1612 for more information. As such, the behavior you describe makes sense to me, since you changed MATLAB versions; perhaps MATLAB and OpenSim were both compiled with Visual Studio 2015.

If you're interested in hiding OpenSim's print statements, you could try something like this: http://www.mathworks.com/help/matlab/re ... fc15c32635

User avatar
Pavlos Silvestros
Posts: 43
Joined: Sun Oct 16, 2016 4:10 am

Re: Matlab2017a prints results of supressed API functions

Post by Pavlos Silvestros » Fri Sep 22, 2017 1:12 am

Hi Chris

Thanks for the information!

I'll try and work around the problem from what you have said.

Thanks again.

Best regards,
Pavlos

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab2017a prints results of supressed API functions

Post by Christopher Dembia » Fri Sep 22, 2017 12:50 pm

FYI the code that manages the logging is here: https://github.com/opensim-org/opensim- ... gManager.h

POST REPLY