How do i separate running data?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Malthe Bilgram
el 7 de Mayo de 2018
Comentada: Malthe Bilgram
el 9 de Mayo de 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 :)
0 comentarios
Respuesta aceptada
sloppydisk
el 7 de Mayo de 2018
Editada: sloppydisk
el 7 de Mayo de 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 comentarios
sloppydisk
el 9 de Mayo de 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.
Más respuestas (1)
Jan
el 9 de Mayo de 2018
Editada: Jan
el 9 de Mayo de 2018
The problem is not easy. The posted file contains these values in Data{2}:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/188332/image.png)
The question contains these details:
- "only want to use the data from the right foot"
- "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.
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!