Prev: Rewriting equality or inequality constrains for fmincon or quadprog
Next: dynamic figures -- too much
From: Philip on 20 May 2010 16:03 Hello, I'm currently using MATLAB to analyse some accelerometer and EMG data of the press-up cycle for various press-up stances, e.g. wide, preferred, narrow. I am currently having an issue trying to determine how many press ups have been done from the graph (I know its 4, and I can see its 4, I just need to write something into the program so it can detect this, so another signal with a different amount of press-ups could be used and the value outputted). I have worked out the maximum value and set a threshold at 80% of this. Currently I have a graph with a curve that has 4 peaks above the threshold (therefore 8 crossings) but I want to write a loop that will increase a counter by 1 everytime the threshold is crossed. I was then planning on dividing the count by 2 to find the amount of press ups. I currently have variables named: accx % accelerometer data in x maxaccx % maximum value of accx thresh % maxaccx*0.8 Any help would be much appreciated. Thank you Philip
From: Walter Roberson on 20 May 2010 16:14 "Philip " <wibs2k(a)hotmail.com> wrote in message <ht44hq$61r$1(a)fred.mathworks.com>... > I have worked out the maximum value and set a threshold at 80% of this. Currently I have a graph with a curve that has 4 peaks above the threshold (therefore 8 crossings) but I want to write a loop that will increase a counter by 1 everytime the threshold is crossed. I was then planning on dividing the count by 2 to find the amount of press ups. More direct would be to count only one side or the other. sum( X(1:end-1) < threshold & X(2:end) > threshold ) You might want to do some smoothing on the data to prevent it finding places that peak above the threshold (noise) and then coming down again before rising to the true peak. Also, you need to decide what to do about the possibility of values right *at* the threshold.
From: someone on 20 May 2010 16:14 "Philip " <wibs2k(a)hotmail.com> wrote in message <ht44hq$61r$1(a)fred.mathworks.com>... > Hello, > > I'm currently using MATLAB to analyse some accelerometer and EMG data of the press-up cycle for various press-up stances, e.g. wide, preferred, narrow. > > I am currently having an issue trying to determine how many press ups have been done from the graph (I know its 4, and I can see its 4, I just need to write something into the program so it can detect this, so another signal with a different amount of press-ups could be used and the value outputted). > > I have worked out the maximum value and set a threshold at 80% of this. Currently I have a graph with a curve that has 4 peaks above the threshold (therefore 8 crossings) but I want to write a loop that will increase a counter by 1 everytime the threshold is crossed. I was then planning on dividing the count by 2 to find the amount of press ups. > > I currently have variables named: > > accx % accelerometer data in x > maxaccx % maximum value of accx > thresh % maxaccx*0.8 > > Any help would be much appreciated. > > Thank you > > Philip I'm not sure you need to use a loop. doc diff Try setiing values greater than (or equal) to your threshold to one and values less than you threshold to zero. Then use the diff command. Negative and positive diff values are where you cross the threshold.
From: ImageAnalyst on 20 May 2010 16:19 Philip: Do you have the Image Processing Toolbox? If so, you're in luck. It's just one line: % Create 4 regions of sample data accx = [10 9 7 9 10 10 10 7 7 10 10 7 10] % accelerometer data in x maxaccx = 10 % maximum value of accx thresh = 0.8 * maxaccx % maxaccx*0.8 % Do the thresholding. thresholdedData = accx > thresh % Now do what Philip wants..... % One single line to count the number of times % the signal exceeds the threshold. [labeledData, numberOfRegions] = bwlabel(thresholdedData)
From: Philip on 20 May 2010 16:22 "Walter Roberson" <roberson(a)ibd.nrc-cnrc.gc.ca> wrote in message <ht456c$jmq$1(a)fred.mathworks.com>... > "Philip " <wibs2k(a)hotmail.com> wrote in message <ht44hq$61r$1(a)fred.mathworks.com>... > > > I have worked out the maximum value and set a threshold at 80% of this. Currently I have a graph with a curve that has 4 peaks above the threshold (therefore 8 crossings) but I want to write a loop that will increase a counter by 1 everytime the threshold is crossed. I was then planning on dividing the count by 2 to find the amount of press ups. > > More direct would be to count only one side or the other. > > sum( X(1:end-1) < threshold & X(2:end) > threshold ) > > You might want to do some smoothing on the data to prevent it finding places that peak above the threshold (noise) and then coming down again before rising to the true peak. Also, you need to decide what to do about the possibility of values right *at* the threshold. The data has already had a low pass filter on it to remove the noise from the data . And if it hits the threshold I understand what you mean because there would be an odd number of crossings. For the extent of my program it is safe to assume that this wont happen (or at least I hope not)... all I need it to do is tell me how many times it crosses the threshold! I'm struggling with the solution you said... not entirely sure what to do with it Cheers Philip
|
Next
|
Last
Pages: 1 2 Prev: Rewriting equality or inequality constrains for fmincon or quadprog Next: dynamic figures -- too much |