Normalize different size arrays to all be 100 points long with resample

14 views (last 30 days)
I am trying to normalize gait data to the gait cycle for a bunch of subjects. Each subject has a different length gait cycle. For example, if one subject has 115 data points over the gait cycle, another has 150. All data is collected at the same frequency. I would like to normalize the data so I have 100 points over the gait cycle for every subject. This is done for 50 subjects, so I would like to be able to normalize without inputting how long the current data set is. I was trying to play around with the resample function but can't figure out how to get the parameters correct. Advice?

Accepted Answer

Star Strider
Star Strider on 27 Sep 2019
Using resample (or any other interpolation method, although resample is best for signal processing applications) to get the same number of data for each subject risks having a different sampling frequency for each subject. This also means that any signal processing you do (such as filtering) would have to be individualised for each subject, as would subsequent data analysis. So I would advise against that.
You could likely do it by using the ‘p’ and ‘q’ parameters as the integer values of the actual and desired record lengths, since resample just needs those values to change the sampling frequency (and record length) of the argument vector. (It cares not one whit what the numbers actually represent.) However for the reasons I already mentioned, this is unadvisable.
Use cell arrays to store the varying-length records, with the same sampling frequency for all of them, and then use the same analytical techniques for every subject.
  4 Comments
Star Strider
Star Strider on 9 Mar 2021
husnir nasyuha — I would consider using resample first to get them all to have the same sampling frequency, the do the rest as explained here. Understand the hazards involved in doing that, though.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!