MATLAB Answers

Translated by

이 페이지의 내용은 영어에서 자동 번역되었습니다. 자동 번역 기능을 해제하려면 "<a class="turn_off_mt" href="#">여기</a>"를 클릭하십시오.


computing second derivative from txt/csv file based on existing excel algorithm

Asked by Dariusz Mosler on 15 Apr 2019
Latest activity Commented on by Dariusz Mosler on 19 Apr 2019
Accepted Answer by dpb
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?


"how do I compute columns values row to corresponding row?"
Can you explain what, precisely, you mean by the above?
A short example with inputs and expected outputs and how the output follows from the input would be best...

Sign in to comment.




2 Answers

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; % 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...


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

Please see the excel file. There is T value for time X, Y, Z for position in time for markers. =(B4/1000-B3/1000)/($A4-$A3) for example (x4/1000-x3/100)/(t4-t3). I do not know how to adress colums and values as it is in excel. If I state in matlab t2 = varx(:, 2) to have x value column and the same matter t column, what should I write to compute the same pattern as in excel? I am providing sample of txt file.


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.
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.
Thank you very much for recommending Octave. Code runs after I added signal package. It may be sufficient for now and further learning

Sign in to comment.

Translated by