High Pass Filter Error
14 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Star Strider
on 13 Apr 2021
Edited: Star Strider
on 14 Apr 2021
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 Comments
Star Strider
on 14 Apr 2021
Edited: Star Strider
on 14 Apr 2021
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')
.
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!