Page 1 of 1

Matlab commands for creating scale setup file

Posted: Fri Mar 05, 2021 3:48 am
by sheebadavis
Hi

I am trying to replicate Gait2354 model's scale setup file (provided in the OpenSim distribution) using matlab. I need some guidance in setting marker pair names.
<MarkerPair name="">
<!--Names of two markers, the distance between which is used to compute a body scale factor.-->
<markers> V.Sacral Top.Head </markers>
</MarkerPair>
I tried with the following commands in matlab to set the marker names:

Code: Select all

>> myMarkerPair=MarkerPair()
myMarkerPair =
>> myArrayStr=ArrayStr()
myArrayStr =
org.opensim.modeling.ArrayStr@6c518474
>> myArrayStr.set(0,'V.Sacral');
>> myArrayStr.set(1,'Top.Head');
>> myMarkerPair.setMarkerName(myArrayStr);
No method 'setMarkerName' with matching signature found for class 'org.opensim.modeling.MarkerPair'.
But i get an error. I doubt whether the argument is in ArrayStr form. Some help is appreciated.

Thanks in advance
Sheeba

Re: Matlab commands for creating scale setup file

Posted: Fri Mar 05, 2021 12:34 pm
by aymanh
Hello,

The signature of the method is

Code: Select all

setMarkerName(int i, String aName)
So you should call the method twice, once per MarkerName

In general you should use the methodsview command in Matlab to see the sugnatures of available methods (names, parameter types etc.)

Hope this helps,
-Ayman

Re: Matlab commands for creating scale setup file

Posted: Sat Mar 06, 2021 1:56 am
by sheebadavis
Hi Ayman

Thanks for your help. I now understood how it is done.

I have another doubt: If i have to remove a section from the xml file (for ex: Measurement section in a scale setup file), is xml editor (notepad++) the only option or can we do it (remove/replace) it in Matlab?

Thanks Sheeba

Re: Matlab commands for creating scale setup file

Posted: Sat Mar 06, 2021 5:34 am
by tkuchida
I think the easiest way is a text editor, though you could absolutely do it programmatically---by treating the file as a generic XML file or even as plain text.

Re: Matlab commands for creating scale setup file

Posted: Sun Mar 07, 2021 10:02 pm
by sheebadavis
Hi Thomas

Thanks for your response. If it can be done in Matlab, can you please tell me what command i need to use to remove/replace a section in an XML file.

Regards
Sheeba

Re: Matlab commands for creating scale setup file

Posted: Mon Mar 08, 2021 10:05 am
by tkuchida
A very simple strategy would be to open the original file (open in "read" mode), create a new file (open in "write" mode), read each line in the original file one-by-one, and write to the new file only the lines you wish to retain. You can use the "strcmp" function to find lines in the file.

Re: Matlab commands for creating scale setup file

Posted: Mon Mar 08, 2021 9:02 pm
by sheebadavis
Hi Thomas

Thanks for your response.

The procedure you mentioned is done using Matlab commands and i was curious to know if there was any class (commands in doxygen - OpenSim & Matlab interface) that would do modify (delete/remove/replace) the xml file.

Regards
Sheeba