Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Butter Filter doesn’t work

1 visualización (últimos 30 días)
Melika Eft
Melika Eft el 14 de Mzo. de 2023
Cerrada: Rik el 14 de Mzo. de 2023

Hello I just wrote this code and I have an error in line which I use butter filer thanks for your help

% Define the bandpass signal (sine wave) fs = 1000; % sampling frequency t = 0:1/fs:1-1/fs; % time vector f1 = 100; % signal frequency f2 = 300; % signal frequency x = sin(2*pi*f1*t) + sin(2*pi*f2*t); % bandpass signal

% Obtain the Fourier transform of the bandpass signal X = fft(x);

% Define the cutoff frequency for the lowpass filter fc = 500; % cutoff frequency

% Create a Butterworth lowpass filter N = 4; % filter order [b,a] = butter(N, fc/(fs/2));

% Apply the filter to the Fourier transform of the signal Y = filter(b, a, X);

% Obtain the time-domain representation of the filtered signal y = real(ifft(Y));

% Plot the original and filtered signals figure; subplot(2,1,1); plot(t,x); title('Bandpass Signal'); xlabel('Time (s)'); ylabel('Amplitude'); subplot(2,1,2); plot(t,y); title('Lowpass Filtered Signal'); xlabel('Time (s)'); ylabel('Amplitude');

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by