How to apply butterworth filter to data in cells? filter went wrong
Show older comments
Hi all,
I have signals of diffrent lengths located in cells (attached), that when plotted over one plot looks like this.

My aim is to:
- interpolate all cells to 101 data points
- apply butterworth filter to data in all cells
load 'cells'
% Interpolate data
force_y_l_cycle = cellfun(@(x) interpft(x,101), force_y_l_cycle, 'uni', 0);
% Filter data
SampRate=1000;
Wn=SampRate/2;
order=2;
cutoff=6;
[b,a] = butter(order,cutoff/Wn,'low');
for k = 1:length(force_y_l_cycle)
force_y_l_cycle{k} = filtfilt(b, a, force_y_l_cycle{k});
end
% Plot
hold on
for i = 1:length(force_y_l_cycle)
plot(force_y_l_cycle{i},'r') ;
xlabel('% of cycle'); ylabel('force y l (N)'); box off; axis tight;
end
This results in:
Interpolated:

Filtered results is this.

If I chnage the order so first filtering and then interpolation I get this, which is better but still the last data poits shoudl be closer to 0.
I wonder where do I make a mistake in my approach ? Can you help please?

Accepted Answer
More Answers (1)
William Rose
on 18 Jul 2022
0 votes
@Tomaszzz, You're welcome. Good lcuk with your research.
Categories
Find more on Butterworth 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!