Asked by Dariusz Mosler
on 15 Apr 2019

Hi everyone,

I am new to Matlab. I have trouble finding anwsers to my problem. I decided to try Matlab for faster computing of my problem. I am working on my PhD from biomechanics as physiotherapist. I haave captured data from c3d files and by mokka software it can be exported for selected markers to txt file. In excel, each time I need to paste exported data to excel algoritm which I attached in a file here. Then I need to find max velocity of each move (three kicks captured for one file). It is time consuming in excel. i need to do it about 400 times. Each time it gave me only 3 results and takes around 10-15 minutes to do it. I had idea of making macro in Matlab. I want to write an alogrithm for skipping some steps. I want to import file, compute second derivative (t time, xyz -marker positions), and then find max values from 3 sectors -rows 0-700, 701-1400, 1401-2100. I cannot find commands for computing this in a same manner as it is in this excel file. Can you at least guide me how do I compute columns values row to corresponding row?

Answer by dpb
on 16 Apr 2019

Edited by dpb
on 16 Apr 2019

Accepted Answer

Here's perfect example why Matlab excels over Excel... :)

txyz=importdata('B0264_dollyo_air_P_T01 rtoe.txt',',',8); % read the text file

txyz=txyz.data; % all data in array time,x,y,z

dxyz=diff(txyz); % first differences of all columns

vxyz=dxyz(:,2:end)./dxyz(:,1)/1000; % compute velocity components

v=sqrt(sum(vxyz.^2,2)); % and the total velocity

One doesn't need to keep all the intermediary variables unless there's other need for them; kept here so can look at them and see how matches up.

The text file and the Excel file aren't the same data and the Excel file has the European "," for the decimal point so it's hard to read here in the US w/o other machinations so couldn't directly illustrate it does give identical result...

BTW, despite the Q? title, there's only a first derivative, not second...if need the second, you just "rinse and repeat" the above or use the second, optional argument to diff to compute it directly if don't need the first but this was just a step along the way...

Dariusz Mosler
on 16 Apr 2019

Thank you very much! This will help me a lot.

I propably made a mistake translating math terms.

Best wishes for you

Sign in to comment.

Answer by Dariusz Mosler
on 15 Apr 2019

Dariusz Mosler
on 18 Apr 2019

If you are using gps for farming you have much acre of fields. I hope weather will be favourable for you. I did not get the anwser from my country distributor about different licences. I learnd about scilab being free. I feel it is worse than matlab. I was unable to covert your code fully. I ask thier community, but their use only mailing list, so even for forum they are inferior. I can afford home license because it is 180 euro but full comiercial is too much for now. Whole month payment for me.

But maths problems and learining is much more fun now than gaming.

dpb
on 19 Apr 2019

I'm not sure on the non-US licensing arrangements, sorry.

I'd think Mathworks US would answer an enquiry e-mail though and be eager to know of any sales associates that aren't responsive so they could take action.

The closest thing I know of altho I've never actually used it is Octave -- as said, I don't know about some of the more esoteric features in toolboxes, but the base product is pretty-much same functionality/syntax.

Dariusz Mosler
on 19 Apr 2019

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 1 Comments

## dpb (view profile)

## Direct link to this comment

https://kr.mathworks.com/matlabcentral/answers/456568-computing-second-derivative-from-txt-csv-file-based-on-existing-excel-algorithm#comment_694461

Sign in to comment.