Determining index based on a condition

8 次查看(过去 30 天)
Jessica Thomas
Jessica Thomas 2016-2-22
回答: Aashray 2025-2-8,13:40
I have a 6001x194 matrix which includes various data from an experiment where subjects walked on a treadmill with 2 force plates (one for each foot). Column 140 and 157 are the force plate data for each of the force plates. I want to determine the time points of toe-offs and heel strikes for the right foot (based on the force plate data from column 140).
Toe-off is considered the first time point where the force plate data is less than 5N after being above 5N in the time frame below. Heel strikes are considered to be the first time point the force plate data is above 20N after being below 20N in the time frame before.
In the end I want 2 separate variables. One would be giving me the index of the toe-off time points and the other giving me an index of the heel strike time points.

回答(1 个)

Aashray
Aashray 2025-2-8,13:40
Hello Jessica,
You need to create two answer vectors, one for storing the index of “Toe-off” moments, and other for “Heel-down”. A simple for loop can be used for iterating the whole 140th column, along with 2 flags to capture the current state.
If the Heel-down flag ("flag1") is true, then look for the index of first value after current time instant which is less than 5N, and if the Toe-off flag ("flag2") is true, then look for the index of first value after current time instant which is greater than 20N. As soon as the value is found, the corresponding index can be pushed into the respective vector.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by