unsure whether to resample or interp(1)?

조회 수: 1 (최근 30일)
caroline bourn
caroline bourn . 2021년 3월 23일
댓글: Mathieu NOE . 2021년 4월 2일
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,:) = [];
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;
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;
next = pts(i);
bigarray{i} = new_location;
re_sample{i} = new_sample;
%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
Mathieu NOE
Mathieu NOE 2021년 4월 2일
hello Caroline
I would try with interp1
all the best

댓글을 달려면 로그인하십시오.

답변 (0개)


Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by