unsure whether to resample or interp(1)?

2 views (last 30 days)
caroline bourn
caroline bourn on 23 Mar 2021
Commented: Mathieu NOE on 2 Apr 2021
hi! i have some data that needs to be resampled? i think. The original data is varying in row length dependant on the test. ie. test 1 could have 1600 rows, test two could have 1100 and test 3 could have 3000 rows.
should i be re-sampling or interp?
currently i am resampling but i am not getting the same number of rows for each walk. I am sampling data at a frequency of 100Hz. i ideally would like them to be 1000 rows each.
i have tried
resample(new_location,1,1); %and
resample(new_location,FS,1,10) %WHERE FS IS 100Hz
% %
i have attached an excel file of my data where the columns are the following respectively.
foot contact #, time, left/right foot, x co-ordinate, y co-ordinate.
this is the code i have so far.
zero = COP(:,2) == 0;
COP(zero,:) = [];
COP = COP;
finalrow = length(COP);
pts = findchangepts(COP(:,2), 'Statistic', 'linear', 'MinThreshold',50);
pts(end+1) = finalrow; %adds another point to array (final)
next = 1;
k_footfall = COP(:,1);
time = COP(:,2);
left_right_f = COP(:,3);
x = COP(:,4);
y = COP(:,5);
bigarray = {};
% this section of code finds the row location of the new walk and flips
% the corresponding rows so that the rows all start from the the same
% origin.
for i=1:length(pts);
if mod(i,2) == 0
new_location = [k_footfall(next:pts(i,:)), time(next:pts(i,:)),left_right_f(next:pts(i,:)), x(next:pts(i,:)), y(next:pts(i,:)) ];
new_sample(:,1) = i;
else
new_location = [k_footfall(next:pts(i,:)), time(next:pts(i,:)),left_right_f(next:pts(i,:)), 350- (x(next:pts(i,:))), y(next:pts(i,:))];
new_sample = resample(new_location,1,1);
new_sample(:,1) = i;
end
next = pts(i);
bigarray{i} = new_location;
re_sample{i} = new_sample;
end
%vertically concatenating the data
COP_location = vertcat(bigarray{:})
resample_x = vertcat(re_sample{:});
%finds the unique values. ie. how many data points for each walk
[C2,iac,icb] = unique(resample_x(:,1));
a_counts_walk = accumarray(icb,1);
value_counts_walk = [C2, a_counts_walk];
  5 Comments
caroline bourn
caroline bourn on 1 Apr 2021
thank you for that! is there a function you would suggest? :)
Mathieu NOE
Mathieu NOE on 2 Apr 2021
hello Caroline
I would try with interp1
all the best

Sign in to comment.

Answers (0)

Categories

Find more on Fit Postprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!