Azzera filtri
Azzera filtri

How do i separate running data?

7 visualizzazioni (ultimi 30 giorni)
Malthe Bilgram
Malthe Bilgram il 7 Mag 2018
Commentato: Malthe Bilgram il 9 Mag 2018
Hey,
i have measured running on a treadmill with an integrated pressure sensor and i get an output from both the left and right foot. The thing is, i only want to use the data from the right foot, so i need a way to discard the data from the left foot and keep the right (like replacing all left foot data with 0). I'm quite new to matlab, so i have absolutely no idea how to do it. I have an idea with setting a threshold to 20 newton, and then using a counter to distinguish whenever i'm getting to the start of a new data series (it gets to zero after every step). The test protocol is made so that the first step is always the right, so figuring out which data peak is which foot, is not the problem. If this made no sense at all, please say so, and i will try to elaborate.
I've added the data file, for you to mess around with, if that is any help.
Thank you :)

Risposta accettata

sloppydisk
sloppydisk il 7 Mag 2018
Modificato: sloppydisk il 7 Mag 2018
This is actually a really fun job for a new user. Please look into logical indexing https://nl.mathworks.com/help/matlab/math/matrix-indexing.html#bq7eg38 . I actually separated your data, but it was so fun to do I wouldn't want to ruin it for you by spoiling the answer. Your data is very nice, because it's already noise-free so it should be quite doable. If you can't manage just message me and I'll send you my code.
Hint: use something like
starts = find(data(2:end)>0 & data(1:end-1)==0) + 1;
to find the start positions.
  7 Commenti
sloppydisk
sloppydisk il 9 Mag 2018
You're very welcome. I noticed a small mistake though, first line in the loop should be:
firstfoot(startsFirst(i):endsFirst(i)) = 0;
Instead of
firstfoot(startsFirst(i):startsSecond(i)) = 0;
It doesn't really matter in this case because there is no noise though.
Malthe Bilgram
Malthe Bilgram il 9 Mag 2018
Thanks again! I'll just correct it in the script, just in case :)

Accedi per commentare.

Più risposte (1)

Jan
Jan il 9 Mag 2018
Modificato: Jan il 9 Mag 2018
The problem is not easy. The posted file contains these values in Data{2}:
The question contains these details:
  1. "only want to use the data from the right foot"
  2. "the first step is always the right"
This means, that you want the tiny block on the left only and remove the long block on the right?
[EDITED] Ah, I've zoomed into the diagram. These are not 2 blocks only, but some hundreds of blocks.
FileData = load('S4_pre_q_p.mat');
Thresh = 20;
Sig = (FileData.Data{2} >= Thresh);
[B, N] = RunLength(Sig);
match = find(B);
B(match(2:2:end)) = false;
Mask = RunLength(B, N);
Cleaned = FileData.Data{2} .* Mask;
This sets the signal of each 2nd block above the threshold beginning with the 2nd one to 0.
If you do not have a C compiler installed, you can use the slower Matlab version RunLength_M from the same submission instead of the C-Mex version RunLength().
Maybe you want to crop the first block - then use:
B(match(1:2:end)) = false;
By the way, your signal seems like you can reduce the threshold to exactly 0.
  1 Commento
Malthe Bilgram
Malthe Bilgram il 9 Mag 2018
Thank you for your answer Jan! The small block on the left is taps we did onto a treadmill with integrated pressure sensor, as to have something to synchronize a sound recording to this (was not possible to record it on the same system an synchronize it that way). The right part is what i'm interested in. It is all the steps done in a 1 minute and 30 second long run :) But Jasper came up with just the answer i needed, but thanks alot again for your contribution! :)

Accedi per commentare.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by