reading a ".mot" file

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

reading a ".mot" file

Post by hamed kouchebaghi » Fri Sep 04, 2020 11:58 pm

Hello,

how can I read a .mot file in MATALB? there was a topic in "Scripting with Matlab" about "Reading in and Writing Data to File".
there was a code like this

Code: Select all

filepath = 'subject01_walk1_grf.mot';
and I typed the file path containing the .mot file and run it in MATLAB but that didn't work.
could you help me with this problem please..

thank you,
Hmaed

User avatar
Michael Asmussen
Posts: 67
Joined: Mon Jul 11, 2016 7:46 am

Re: reading a ".mot" file

Post by Michael Asmussen » Mon Sep 07, 2020 12:14 pm

Hi Hmaed,

In the past, I have used "dlmread" in Matlab to import the coordinate data of a .mot file and then "readtable" to extract the variable names.

I hope this is helpful

Mike

User avatar
Evan Dooley
Posts: 25
Joined: Fri Sep 27, 2019 8:36 am

Re: reading a ".mot" file

Post by Evan Dooley » Mon Sep 07, 2020 3:59 pm

Hey,

I was actually working on this today. Here's what I came up with:

Code: Select all

IKrez_0 = readtable([trialname,'_0_IKrez.txt']);
outputs = IKrez_0.Properties.VariableNames;
data = table2array(IKrez_0);
The input to the readtable is a string of the file name for the inverse kinematics results. I had them print to a txt extension instead of mot because the readtable function didn't support the mot file type. Then calling the variable names from the data gives you all of the column headers and table2array pulls all of the numerical data out of the table into one matrix.

Hope that helps.

Best,
EAD

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: reading a ".mot" file

Post by hamed kouchebaghi » Tue Sep 08, 2020 4:12 am

edooley wrote:
Mon Sep 07, 2020 3:59 pm
Hey,

I was actually working on this today. Here's what I came up with:

Code: Select all

IKrez_0 = readtable([trialname,'_0_IKrez.txt']);
outputs = IKrez_0.Properties.VariableNames;
data = table2array(IKrez_0);
The input to the readtable is a string of the file name for the inverse kinematics results. I had them print to a txt extension instead of mot because the readtable function didn't support the mot file type. Then calling the variable names from the data gives you all of the column headers and table2array pulls all of the numerical data out of the table into one matrix.

Hope that helps.

Best,
EAD
hey,

thank you very much for your response.
I've got a few questions. what should I put instead of "trialname", "_0_IKrez.txt", and "IKrez_0" ? I think I have to put the file path containing the .txt of the motion file instead of "_0_IKrez". Am i right ??

thank you, Best
Hamed

User avatar
Evan Dooley
Posts: 25
Joined: Fri Sep 27, 2019 8:36 am

Re: reading a ".mot" file

Post by Evan Dooley » Tue Sep 08, 2020 6:02 am

Yep that's the filename, mine just loops a bunch of trials so that's how it formats to read. I think from what you gave yours would be:

Code: Select all

motAsTable = readtable('subject01_walk1_grf.txt');
outputs = motAsTable.Properties.VariableNames;
data = table2array(motAsTable);
Yeah, the mot file is just saved as a txt file, so that the readtable function will take it in.

If the script you're using is outside of the data folder, then you would need the whole path to the file, otherwise just the filename should suffice.

Hope that helps,
EAD

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: reading a ".mot" file

Post by hamed kouchebaghi » Thu Sep 10, 2020 12:34 am

edooley wrote:
Tue Sep 08, 2020 6:02 am
Yep that's the filename, mine just loops a bunch of trials so that's how it formats to read. I think from what you gave yours would be:

Code: Select all

motAsTable = readtable('subject01_walk1_grf.txt');
outputs = motAsTable.Properties.VariableNames;
data = table2array(motAsTable);
Yeah, the mot file is just saved as a txt file, so that the readtable function will take it in.

If the script you're using is outside of the data folder, then you would need the whole path to the file, otherwise just the filename should suffice.

Hope that helps,
EAD
I entered the following code:

Code: Select all

motAsTable = readtable('C:\OpenSim 4.1\Models\Arm26\OutputReference\InverseKinematics\arm26.txt');
outputs = motAsTable.Properties.VariableNames;
data = table2array(motAsTable);
unfortunately that didn't go right, and this error shows on the window

Code: Select all

Error using table2array (line 27)
Cannot concatenate the table variables 'Var1' and 'Var2', because their types are double and cell.

Error in arm26 (line 10)
data = table2array(motAsTable);
you know.. I want I have loaded arm26 model on my screen through MATLAB and at this step I want to load the motion file.

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: reading a ".mot" file

Post by hamed kouchebaghi » Fri Sep 11, 2020 11:13 pm

mjasmuss wrote:
Mon Sep 07, 2020 12:14 pm
Hi Hmaed,

In the past, I have used "dlmread" in Matlab to import the coordinate data of a .mot file and then "readtable" to extract the variable names.

I hope this is helpful

Mike
thank you for your response in advance,
I changed the .mot file to a .txt format and then used the "readtable" but that didn't load the motion.
here is the code that I used:

Code: Select all

motAsTable = readtable('C:\OpenSim 4.1\Models\Arm26\OutputReference\InverseKinematics\arm26.txt');
outputs = motAsTable.Properties.VariableNames;
thanks,
Hamed

User avatar
hamed kouchebaghi
Posts: 47
Joined: Thu Nov 14, 2019 12:11 pm

Re: reading a ".mot" file

Post by hamed kouchebaghi » Mon Sep 21, 2020 6:52 am

edooley wrote:
Tue Sep 08, 2020 6:02 am
Yep that's the filename, mine just loops a bunch of trials so that's how it formats to read. I think from what you gave yours would be:

Code: Select all

motAsTable = readtable('subject01_walk1_grf.txt');
outputs = motAsTable.Properties.VariableNames;
data = table2array(motAsTable);
Yeah, the mot file is just saved as a txt file, so that the readtable function will take it in.

If the script you're using is outside of the data folder, then you would need the whole path to the file, otherwise just the filename should suffice.

Hope that helps,
EAD
hello Emily,

I have trouble loading .mot file.
could you help me with this. Were you able to do it yourself?

thanks,
Hamed

POST REPLY