High Pass Filter Error

21 ビュー (過去 30 日間)
Davide Mastrodicasa
Davide Mastrodicasa 2021 年 4 月 13 日
編集済み: Star Strider 2021 年 4 月 14 日
Hello everyone,
I'm having some problems in solving a problem I have with an High Pass filter. I just want to filter a signal with an High Pass Filter with a cut off frequency of 5 Hz. This is my simple script:
F_cutoff=5;
ii=1; % I'm just taking the first row to have a simple example.
fs=400;
u_G_Interp(ii,:)=highpass(u_G_Interp(ii,:),F_cutoff,fs); % u_G_Interp is a simple time signal matrix where each row is the signal that I want to filter. The dimension is [2923 x 1024]
If I use F_cutoff > of a certain value that depends case by case I don't get any error but If it is lower than a certain value I have an error like this:
Error using designfilt>parseAndDesignFilter (line 516)
Size inputs must be integers.
Error in designfilt (line 224)
[err,requestedResponse,parseParams,h] = parseAndDesignFilter(inputParamValueNames, varargin{:});
Error in highpass>designFilter (line 194)
opts.FilterObject = designfilt(params{:});
Error in highpass (line 97)
opts = designFilter(opts);
I'm not an expert on filtering so I don't understand where exactly the problem is. Is there any constraint in using these filters that I'm not considering?
Yhank you in advance for your help.
Davide

回答 (1 件)

Star Strider
Star Strider 2021 年 4 月 13 日
編集済み: Star Strider 2021 年 4 月 14 日
The problem may be with ‘u_G_Interp’, and since we do not have it to work with, we cannot determine that.
Assuming it is a double array, try this:
u_G_Interp = randn(1923,1024); % Create Signal Matrix
F_cutoff=5;
fs = 400;
[u_G_InterpFiltT(ii,:),df] = highpass(u_G_Interp(ii,:), F_cutoff, fs); % Filters Signal Column-Wise, So Transpose To Filter Rows
.
  2 件のコメント
Davide Mastrodicasa
Davide Mastrodicasa 2021 年 4 月 14 日
編集済み: Davide Mastrodicasa 2021 年 4 月 14 日
Thank you for your answer.
I tried with your example and it works perfectly but I don't get the point on why it doen't work on my dataset. Is there any constraint on the function that can led to this error?
You can find a row of my dataset in attachment. On this data, with a cutoff frequency of 2 Hz, I get the error I posted in the question. My data set, as you said, is a double array.
Star Strider
Star Strider 2021 年 4 月 14 日
編集済み: Star Strider 2021 年 4 月 14 日
The only problem I can see with respect to ‘F_cutoff’ is that it must be less than fs/2 which is the Nyquist frequency. I have tried it with ‘F_cutoff’ values ranging from 0.001 to 199 and it has not thrown any errors. The values for it that threw the error were not posted, so I have no idea what the problem could be.
This runs for me without error and produces the expected result:
LD = load('Data.mat');
u_G_Interp = LD.u_G_Interp;
ii=1;
F_cutoff=5;
fs = 400;
L = size(u_G_Interp,2);
t = linspace(0, L, L)/fs;
figure
plot(t, u_G_Interp(ii,:))
grid
xlabel('Time')
title('Original Signal')
Fn = fs/2;
FTuGI(ii,:) = fft(u_G_Interp(ii,:))/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTuGI(Iv))*2)
grid
xlabel('Frequency')
title('Fourier Transform')
u_G_Interp_Filt(ii,:) = highpass(u_G_Interp(ii,:),F_cutoff,fs);
figure
plot(t, u_G_Interp_Filt(ii,:))
grid
xlabel('Time')
title('Highpass Filtered Signal')
.

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by