Getting Error in saving values aftering filtering

1 view (last 30 days)
load matrix
Fs=256;
Fn = Fs/2; % Nyquist Frequency
Wp = [2 95]/Fn; % Filter Passband (Normalised)
Ws = Wp .* [0.5 1.2]; % Filter Stopband (Normalised)
Rp=1; % Passband ripple
Rs= 50; % Stopband ripple
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % n is minimum order and Ws is cut-off freq
[b,a] = cheby2(n, Rs, Ws) ;
for k= 1:size(splitedParts,2)
y(k)= filtfilt(b,a,splitedParts (:,k) ) ;
end
There is a matrix of 1024 x 1953 order. I want to save matrix after applying filter in variable 'y'. It should be like if column 1 of splitedParts is filtered, it must be save in column 1 of variable 'y', filtered column2 values must be save in column 2 of variable and so on.
Error I was facing:
In an assignment A(I) = B, the number of elements in B and I must be the same.

Accepted Answer

Star Strider
Star Strider on 28 Jan 2016
Since ‘splitedParts’ is a column vector in each pass, ‘y’ will also be.
Providing (assuming) all are the same length, this will work:
y(:,k)= filtfilt(b,a,splitedParts (:,k) ) ;
an alternative is a cell array:
y{k}= filtfilt(b,a,splitedParts (:,k) ) ;
Note the curly brackets ‘{}’ in the cell array version.

More Answers (0)

Categories

Find more on Filter Banks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!