How to use locminima in a signal with nan values?
Ältere Kommentare anzeigen
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
force_y_r(isnan(force_y_r))=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);
%Plot
x_right = 1:numel(force_y_r);
figure
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:

8 Kommentare
Image Analyst
am 19 Jul. 2022
Where exactly would you want it to find the start and end of each segment?
Image Analyst
am 19 Jul. 2022
Bearbeitet: Image Analyst
am 19 Jul. 2022
Looks like you're trying to find the non-zero sections. I'm not sure why the first two "0" sections don't have starts and ends indicated. Why not?
Do you have the Image Processing Toolbox - could make it easier to find the 0 sections though you could do it with strfind(). It's a little known "trick" that strfind() works with numbers as well as character arrays.
you can find the start and end by using
myData=[1 3 5 3 2 NaN NaN NaN 3 54 2 5 6 2 NaN NaN NaN 3 6 2 7];
ends=strfind(isnan(myData),[0 1])
starts=strfind(isnan(myData),[1 0])+1
Tomaszzz
am 19 Jul. 2022
Image Analyst
am 19 Jul. 2022
Bearbeitet: Image Analyst
am 19 Jul. 2022
Not sure how you can be not sure. It's your data. You must know what you want, right?
Thanks Jonas for the strfind() approach. Tomas, if you still want the other approach I mentioned (with the Image Processing Toolbox), let me know. Or maybe I'll just give both anyway down in the Answers section below.
William Rose
am 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.

Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Interpolation of 2-D Selections in 3-D Grids finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




