Forward Dynamics Analyses in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
RoZi A
Posts: 13
Joined: Sat Feb 06, 2016 10:04 pm

Re: Forward Dynamics Analyses in Matlab

Post by RoZi A » Mon Jul 23, 2018 1:44 pm

Hi Tom,

Thanks for the codes. I wanted to know if the below codes save the analysis results somewhere or no. Because I customized codes but couldn't find the analysis results.
I am looking for a way to add analysis in Forward Dynamics Tool (which is below codes) and save the result in a file or show the results in Workspace Matlab.
Any help is appreciated

Bests,
RoZi

tkuchida wrote:
Sat Feb 11, 2017 2:08 am

Code: Select all

import org.opensim.modeling.*
model = Model('myModel.osim');
ma = MuscleAnalysis();
model.addAnalysis(ma);
ft = ForwardTool();
ft.setModel(model);
ft.setInitialTime(0.);
ft.setFinalTime(1.);
ft.run();

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: Forward Dynamics Analyses in Matlab

Post by Thomas Uchida » Mon Jul 23, 2018 6:09 pm

Unfortunately, I don't have MATLAB on hand for testing, but I would try the printResults() method (https://simtk.org/api_docs/opensim/api_ ... 9c42a24034). You could also use the Analyze Tool; see setupAndRunAnalyzeBatchExample.m here for an example: https://github.com/opensim-org/opensim- ... hExample.m (particularly lines 79-88).

User avatar
RoZi A
Posts: 13
Joined: Sat Feb 06, 2016 10:04 pm

Re: Forward Dynamics Analyses in Matlab

Post by RoZi A » Wed Jul 25, 2018 10:12 am

Hi Tom,

Thanks for your help. I looked through the links you sent and also printResults() in API. My understanding is that to use this tool, we need to specify the directory where the results have been saved, and by using this command we can print that. My problem is that I don't know where the results are locating and I don't know its directory. For example, I wanted to see the muscleAnalysis results of TugOfWar_CompleteRunVisualize.m file . I added the result which I want to see by using addAnalysis() , but I don't know where it's going to be saved after running the file, therefore I can't specify the input of printResults. I wanted to know if the results which I added to the model by addAnalysis() tool, will be saved somewhere after running the model or no. If yes, how can I find the directory?
Thanks a lot

RoZi

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: Forward Dynamics Analyses in Matlab

Post by Thomas Uchida » Wed Jul 25, 2018 7:06 pm

Please see "RunForwardSimulation.m" here: https://github.com/opensim-org/opensim- ... mulation.m. This example script opens a model, adds an analysis, runs a forward simulation, and saves the analysis results to file.

User avatar
RoZi A
Posts: 13
Joined: Sat Feb 06, 2016 10:04 pm

Re: Forward Dynamics Analyses in Matlab

Post by RoZi A » Thu Jul 26, 2018 9:44 am

Hi Tom,

I really appreciate it. That's what I want!

RoZi

POST REPLY