How to use locminima in a signal with nan values?

3 views (last 30 days)
Hi all,
My signal looks like this:
My aim is to identify elements of the signal indicated by green and red circles, which are intercepted by nan values. ( beacuse this is vertical force data in newtons during repetetive jumping).
My aproach is as below:
I wonder whether this can be done without the need to replace nan values with 0 ?
Can you help please?
load 'signal'
%Replace nan values in force with 0
% Identify local minimas at both sides of the flat section
Lv1_right = islocalmin(force_y_r, 'FlatSelection','first', 'MinSeparation',400, 'MinProminence',500);
Lv2_right = islocalmin(force_y_r, 'FlatSelection','last', 'MinSeparation',400, 'MinProminence',500);
start_location_r = find(Lv2_right);
end_location_r = find(Lv1_right);
x_right = 1:numel(force_y_r);
plot(x_right, force_y_r);
hold on
plot(x_right(end_location_r), force_y_r(end_location_r), '^r');
plot(x_right(start_location_r), force_y_r(start_location_r), '^g');
ylabel('Right leg - Force y (N)'); xlabel('Time (samples)');
legend('signal', 'cycle end','cycle start');
hold off
Results in:
William Rose
William Rose on 19 Jul 2022
@Tomaszzz, is it your goal to get time of flight for each jump? Or is it the case that you want the vertical GRF while on the ground, for each segment between jumps? If you had those segments, then you could average them, as we discussed for your walking data in a separate discussion.
Interesting that your forceplate software returns NaNs instead of zero when the subject is airborne. I haven't seen that.
ANalysis of your data is complicated by teh extistence if microgaps in the recording. That is, there are sometimes gaps of one to three points on the shoulders of the takeoffs and landings. For example, see the figure below which shows the landing of the fourth jump. There is numeric data at samples 9710, 9712, 9714 & following. The bue lines and dots are the file data. The magenta lines and dots are data I filled in by linear interpolaiton. The green and red triangles are the start and end points of segments of numeric data.

Sign in to comment.

Accepted Answer

William Rose
William Rose on 19 Jul 2022
Here is the script I usd to make the figure I showed in my comment. It makes two plots, samples of which are below.
William Rose
William Rose on 21 Jul 2022
@Tomaszzz, you are welcome.
My script would probably need adjustment if the recording starts or ends in the middle of a jump (i.e. if the recording begins or ends with NaNs). If the recording begins with NaNs, then the first marker would be green, not red, and you'd need to adapt "i" versus "i+1" or "i-1" in the loops. If the recordings ends, but does not start, with NaNs, then there will be one more red marker than green. That might cause an issue on the last loop pass.
With the recording you sent, those issues do not arise. It actually looks like you have a complete, or almost complete, inter-jump vertical GRF at the start, and another at the end. Since the first is not preceded by NaNs, it is not identified as a segment by my script. The same for the last one, which does not end with NaNs. If you want to include those segment in your analysis, you can add NaNs to the file at the start and end, so those segments would get identified by the script, and then you'd need to make adjustments to the script, as noted above.
Good luck.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!