How to apply butterworth filter to data in cells? filter went wrong
Mostrar comentarios más antiguos
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?

Respuesta aceptada
Más respuestas (1)
William Rose
el 18 de Jul. de 2022
0 votos
@Tomaszzz, You're welcome. Good lcuk with your research.
Categorías
Más información sobre Butterworth en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!