Closing Connection to Log File via Matlab - OpenSim 3.2
Posted: Wed Apr 10, 2024 11:12 am
I am using Matlab 2015b to interface to OpenSim 3.2 and run a series of static optimizations. The script runs just fine and is working as expected; however, I would like to improve how I check whether an optimization was successful.
After an optimization is run, I load and check the `out.log` file for any warnings that occurred:
I'd like input on two questions:
1) Is there a way to delete the log file after each run so that the file does not become massive? When I attempt to delete it at the end of each run, it states that Matlab is still using the file. I'm assuming that a connection to the out.log file is not being closed when the optimization ends.
2) Is there a different way to check if the optimization was successful without using the log file?
Thanks in advance.
After an optimization is run, I load and check the `out.log` file for any warnings that occurred:
Code: Select all
% Check for Simulation Warning
outputContent = fileread('out.log');
% Determine if Warnings Appear
warnStrings = strfind(outputContent, 'WARN- The optimizer could not find a solution at time');
if(~isempty(warnStrings))
currentLogLine = warnStrings(end);
end
1) Is there a way to delete the log file after each run so that the file does not become massive? When I attempt to delete it at the end of each run, it states that Matlab is still using the file. I'm assuming that a connection to the out.log file is not being closed when the optimization ends.
2) Is there a different way to check if the optimization was successful without using the log file?
Thanks in advance.