Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

apply dual filter to cell array

0 views
Skip to first unread message

Teresa

unread,
Nov 9, 2009, 2:25:05 PM11/9/09
to
Hello,

I have a 4x7 cell array where each cell contains 1000 rows of data.

I need to apply a 2nd order butterworth dual low pass (6hz) to each cell... and aviod changing to a matrix.

I am using [b,a] = butter(2,6/500,'low') to get my coefficients but then I don't know how to apply these in the filtfilt function for my cell array.

Any help will be much appreciated!

Thanks,

Teresa

Wayne King

unread,
Nov 9, 2009, 2:51:04 PM11/9/09
to
"Teresa " <tfla...@uottawa.ca> wrote in message <hd9qah$of8$1...@fred.mathworks.com>...

Hi Teresa, use the {i,j} notation to extract the data from the cell array and pass that to filtfilt().

Z = cell(4,7);
Z{3,2}=randn(1000,1);
% the above would already be done presumably by you

[b,a] = butter(2,6/500,'low');
y = filtfilt(b,a,Z{3,2});

Hope that helps,
wayne

Teresa

unread,
Nov 9, 2009, 3:30:18 PM11/9/09
to
Hi Wayne,

your message did indeed help, however, is it possible to apply the filter to every cell in the 4x7 array at the same time? and then output as another 4x7 cell array?

thanks again,

Teresa

"Wayne King" <wmki...@gmail.com> wrote in message <hd9rr8$uv$1...@fred.mathworks.com>...

Wayne King

unread,
Nov 9, 2009, 3:53:01 PM11/9/09
to
"Teresa " <tfla...@uottawa.ca> wrote in message <hd9u4q$o0j$1...@fred.mathworks.com>...

Hi Teresa, if Z is your cell array. How about

Y = cellfun(@(x) filtfilt(b,a,x),Z,'UniformOutput',false);

Hope that helps,
Wayne

Teresa

unread,
Nov 9, 2009, 4:34:02 PM11/9/09
to
Wayne, you just made my day!
Thanks so much!
0 new messages