Filtering a matrix column with different cutoff

I’ ve looking for a method to filter each column of data (101X62) with specific cutoff (1X63). Please, could someone indicate me the problem? Thanks B
x=data
fs=60;
fc=cutoff;
for idx = 1:numel(x);
[b,a] = butter(2, fc/(fs/2));
y = filter(b,a,x); %// output
end

3 件のコメント

Ced
Ced 2016 年 3 月 26 日
currently you are looping over each element of x instead of each column, i.e. you want
Ncols = size(data,2);
for idx = 1:Ncols
% filter next column
end
Also, Xnew does not seem to be defined, and you would of course need to change the cutoff frequency in each loop iteration (right now, it's constant). But your general structure looks ok to me otherwise. What seems to be the problem?
Bruno
Bruno 2016 年 3 月 26 日
Hi Ced, cutoff frequency (1x62) are different for each column.
Ced
Ced 2016 年 3 月 26 日
Yes, but since you are designing your filter in the loop, you can select a different cutoff for each loop iteration, right? Have a look at Image Analyst's answer, he wrote it out for you. You of course still have to define your cutoff vector.

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2016 年 3 月 26 日
編集済み: Image Analyst 2016 年 3 月 26 日

0 投票

Perhaps you meant this:
[rows, columns] = size(data);
y = zeros(size(data));
fs = 60;
for k = 1 : columns
thisColumn = data(:, k); % Extract this one column
fc = cutoff(k); % Extract this one cutoff value.
% Determine filter parameters.
[b,a] = butter(2, fc/(fs/2));
% Do the filtering, and put result into column k of the output y
y(:,k) = filter(b, a, thisColumn);
end

3 件のコメント

Bruno
Bruno 2016 年 3 月 26 日
Thanks for your answer Mat lab show error: [rows, columns] = data
Image Analyst
Image Analyst 2016 年 3 月 26 日
Try
[rows, columns] = size(data);
where data is whatever you called your 2-D array.
Bruno
Bruno 2016 年 3 月 26 日
Thanks, is working now.

サインインしてコメントする。

その他の回答 (0 件)

質問済み:

2016 年 3 月 26 日

コメント済み:

2016 年 3 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by