How can I use lowpass filter while keeping x-axis and y-axis range at log ??
13 views (last 30 days)
Tanmay Das on 30 Dec 2021
You may use the 'loglog' function to plot x- and y-coordinates using a base 10 logarithmic scale on the x-axis and the y-axis. The following code give you better understanding:
% Create a signal sampled at 1 kHz for 1 second. The signal contains two tones, one at 50 Hz and
% the other at 250 Hz, embedded in Gaussian white noise of variance 1/100. The high-frequency tone
% has twice the amplitude of the low-frequency tone.
fs = 1e3;
t = 0:1/fs:1;
x = [1 2]*sin(2*pi*[50 250]'.*t) + randn(size(t))/10;
% Lowpass-filter the signal to remove the high-frequency tone. Specify a passband frequency of 150 Hz.
% Display the original and filtered signals, and also their spectra.
[y,d] = lowpass(x,150,fs); %d is the designed digital filter
% [H,W] = freqz(D,N) returns the N-point complex frequency response
% vector H and the N-point frequency vector W in radians/sample of the
% digital filter, D. The frequency response is evaluated at N points
% equally spaced around the upper half of the unit circle. If N is not
% specified, it defaults to 8192.
[h,w] = freqz(d);
x1 = w/pi;
y1 = 20*log10(abs(h));
% Log-Log scale plot