How to create low pass filter to remove the signal greater than 40pi?

1 visualización (últimos 30 días)
TEOH CHEE JIN
TEOH CHEE JIN el 24 de En. de 2023
Editada: Nayan el 17 de Abr. de 2023
I am designing a filter to remove the unwanted signal in my D(w). The intention is to remove the signal at 4960pi and 5040pi (only w=±40pi is needed). So I use the built-in filter designer tool to remove the signal. I decided to use Chebyshev (Butterworth is also ok) due to its shorter transition band. However, the matlab script has the following error. Nothing was being plotted on the graph too.
This is the specification for my Chebyshev filter.
Signal D(w) has some noise, only the impulse at 40pi is needed. So LPF will suit in this case, but the output has some issue.
This is my script including the previous noise (introduced during modulation and demodulation processes). Any guidance is much appreciated.
%create symbolic functions x, a, b, c, d, e, f_c with independent variable t
syms x(t) a(t) h(t) b(t) c(t) d(t) e f_c(t) f_c1(t) f_c2(t) t tau
%create symbolic functions A, B, C, D, and E with independent variable w
syms A(w) B(w) C(w) D(w) E(w) w
x(t) = cos(100*pi*t);
a(t) = x(0.4*t);
h(t) = dirac(t-0.02);
b(t) = int(a(tau)*h(t-tau), 'tau', -inf, inf);
f_c(t) = 10*cos(2500*pi*t);
f_c1(t) = f_c(t);
f_c2(t) = f_c(t);
c(t) = b(t)*f_c1(t);
d(t) = c(t)*f_c2(t);
figure
subplot (3,1,1)
fplot(a(t))
xlim([-0.05 0.05]),ylim([-1.5 1.5])
title ('Time domain of signal a(t)')
xlabel('Time, t')
ylabel('Amplitude, a(t)')
grid on
A(w) = fourier(a(t), w);
w = -60*pi:0.1*pi:60*pi;
subsA = A(w);
% Replace Inf value with suitable value
idx = subsA == Inf;
subsA(idx) = pi; % choose suitable value from the expression of fourier transform.
subplot (3,1,2)
plot(w,real(subsA));
ylim([0 4])
title ('Frequency domain of signal A(\omega)')
ylabel("\Re(A(\omega))");
xlabel("\omega");
xticks(-40*pi:20*pi:40*pi);
xticklabels({'-40\pi', '-20\pi', '0', '20\pi', '40\pi'})
subplot (3,1,3)
plot(w, angle(A(w)))
title ('Phase spectrum of signal A(\omega)')
ylabel("\angle(A(\omega))");
xlabel("\omega");
figure
subplot(3,1,1)
fplot(b(t))
xlim([-0.05 0.05]),ylim([-1.5 1.5])
title ('Time domain of signal b(t)')
xlabel('Time, t')
ylabel('Amplitude, b(t)')
grid on
syms B w
B(w) = fourier(b(t), w);
w = -60*pi:0.1*pi:60*pi;
subsB = B(w);
% Replace Inf value with suitable value
idx = abs(subsB) == Inf;
subsB(idx) = pi; % choose suitable value from the expression of fourier transform.
subplot (3,1,2)
plot(w,real(subsB));
ylim([0 4])
title ('Frequency domain of signal B(\omega)')
ylabel("\Re(B(\omega))");
xlabel("\omega");
xticks(-40*pi:20*pi:40*pi);
xticklabels({'-40\pi', '-20\pi', '0', '20\pi', '40\pi'})
subplot (3,1,3)
plot(w, angle(B(w)))
ylim([-4 4])
title ('Phase spectrum of signal B(\omega)')
ylabel("\angle(B(\omega))");
xlabel("\omega");
figure
subplot(3,1,1)
fplot(c(t))
xlim([-0.05 0.05]),ylim([-12 12])
title ('Time domain of signal c(t)')
xlabel('Time, t')
ylabel('Amplitude, c(t)')
grid on
syms C w
C(w) = fourier(c(t), w);
%simplify(C(w))
w = -2800*pi:20*pi:2800*pi;
subsC = C(w);
subsC
% Replace Inf value with suitable value
idx = abs(subsC) == Inf;
idx
subsC(idx) = pi; % choose suitable value from the expression of fourier transform.
subplot (3,1,2)
plot(w,real(5*subsC));
%testing = subsC
ylim([0 20])
title ('Frequency domain of signal C(\omega)')
ylabel("\Re(C(\omega))");
xlabel("\omega");
subplot (3,1,3)
plot(w, angle(C(w)))
ylim([-4 4])
title ('Phase spectrum of signal C(\omega)')
ylabel("\angle(C(\omega))");
xlabel("\omega");
figure
subplot(3,1,1)
fplot(d(t))
xlim([-0.1 0.1]),ylim([-110 110])
title ('Time domain of signal d(t)')
xlabel('Time, t')
ylabel('Amplitude, d(t)')
grid on
syms D w
D(w) = fourier(d(t), w);
w = -5050*pi:10*pi:5050*pi;
%simplify(D(w))
subsD = D(w);
%D(w)
% Replace Inf value with suitable value
idx = abs(subsD) == Inf;
subsD(idx) = pi; % choose suitable value from the expression of fourier transform.
subplot (3,1,2)
plot(w,real(25*subsD));
ylim([0 160])
title ('Frequency domain of signal D(\omega)')
ylabel("\Re(D(\omega))");
xlabel("\omega");
subplot (3,1,3)
plot(w, angle(D(w)))
ylim([-4 4])
title ('Phase spectrum of signal D(\omega)')
ylabel("\angle(D(\omega))");
xlabel("\omega");
figure
LPF_fil = lpf;
E = filter(LPF_fil, D);
subplot(3,1,1)
plot(w, E)

Respuestas (1)

Nayan
Nayan el 17 de Abr. de 2023
Editada: Nayan el 17 de Abr. de 2023
As I understand, your problem requires a low pass filtering frequency range from "0-40pi". For this, you are using the filter designer App. Firstly I would like to bring to your observations the following points.
  1. The Fpass entered by you under the filter designer app "Frequency Specifications section" seem to be in terms of angular frequency(radian Hz); however, it is supposed to be in frequency(Hz)
  2. The signal "D" that you want to filter(filter(LPF_fil, D)) has three angular frequency components [40pi, 4960pi, 5040pi]. You would like to filter out 4960pi and 5040pi.
  3. As you can observe in the workspace, D is a symfun datatype; however, a numeric datatype is required. Refer to the documentation to filter(H, x) for better understanding and clarification.
  4. Also, it is required to feed the time domain signal "d(t)" to the filter rather than the frequency domain D(w) of the signal.
Hope this helps!
Cheers!
Nayan

Community Treasure Hunt

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

Start Hunting!

Translated by