How can I use lowpass filter while keeping x-axis and y-axis range at log ??

조회 수: 5 (최근 30일)
Chris
Chris 2021년 11월 14일
답변: Tanmay Das 2021년 12월 30일
How can I use lowpass filter while keeping x-axis and y-axis range at log ??

답변 (1개)

Tanmay Das
Tanmay Das 2021년 12월 30일
Hi,
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
loglog(x1,y1)
where 'lowpass' function filters the input signal x using a lowpass filter, x has been sampled at a rate of fs hertz and fpass=150 is the passband frequency of the filter in hertz.. You may look into 'digitalFilter' documentation for further information.

카테고리

Help CenterFile Exchange에서 Digital Filter Design에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by