unsure whether to resample or interp(1)?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fit Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!