How to filter a signal?

I need to filter a time domain simple signal through a analog low pass filter which i have designed. I need the output signal in time domain.
%LPF
order=3;
ripple = 1; %pass band ripple
f_c= 22e6;
[num1, den1] = cheby1(order, ripple, 2*pi*1.10*f_c, 'low', 's');
%Create input signal
Fs=200e6;
Ts=1/Fs;
NFFT=2^12;
Runtime=(NFFT-1)*Ts;
t=0:Ts:Runtime
a_in=1;
phase_in=0;
y_in=a_in*sin(2*pi*fin*t+phase_in); % 4096 points
I need the output signal y_out in time domain of 4096 points. What do I need to do?

1 Comment

I need to filter a time domain simple signal through a analog low pass filter which i have designed.
Implement your filter in hardware, then run your digital signal through a DAC to create a continuous version of it, and use your filter on the analog signal.

Sign in to comment.

Answers (1)

Hi Bandw W,
if you would like to simulate the output you can use lsim():
%% filter signal
% create system
myFilter = tf(num1,den1);
% apply filter to time domain signal
[y_out, time] = lsim(myFilter,y_in,t);
% plot for check
plot(time,[y_in; y_out'])
Kind regards,
Robert

7 Comments

Hey Robert U,
Thanks for your answer..
I dont need to simulate the output signal ..
I just need the output signal y_out = filtered input..
can i do y_out= myFilter.*y_in; ??
can i some in some way convultion ?
Thanks
Hi Bandw W,
Try out what I wrote you above, and you'll see that is quite what you want. Signal Processing of analogue signals in Matlab on a computer is always a simulation.
Kind regards,
Robert
Hey Robert U,
I did it by our recommendation:
%LPF
order=3;
ripple = 1; %pass band ripple
f_c= 22e6;
[num1, den1] = cheby1(order, ripple, 2*pi*1.10*f_c, 'low', 's');
%Create input signal
Fs=200e6;
Ts=1/Fs;
NFFT=2^20;
Runtime=(NFFT-1)*Ts;
t=0:Ts:Runtime;
a_in=1;
phase_in=0;
fin=175e6;
y_in=a_in*sin(2*pi*fin*t+phase_in); % 4096 points
% filter signal
% create system
myFilter = tf(num1,den1);
% apply filter to time domain signal
[y_out, t] = lsim(myFilter,y_in,t);
% plot for check
plot(t,[y_in; y_out'])
But i dont get the desired attenuation.. at 175 Mhz..
There is attenuation till 50 MHz but higher frequencies the attenuation seems to disaapera.. or mirriored (?)
Hi Bandw W
Using a sample frequency of 200 MHz for a 175 MHz signal frequency violates the Nyquist-Shannon-theorem.
Use at least double sampling frequency than highest signal frequency to be evaluated. Additionally, consider that the simulation is a discrete system. Thus, signal components of higher frequency and high magnitude might lead - without the usage of an anti-aliasing filter - to aliased signal components.
Kind regards,
Robert
Bandw W
Bandw W on 26 Aug 2019
Edited: Bandw W on 26 Aug 2019
Thanks... Let me explain a little better.
A 175 MHz signal , first needs to be filtered by a filter
f_c= 22e6;
[num1, den1] = cheby1(order, ripple, 2*pi*1.10*f_c, 'low', 's'); % Analog Filter not a digital one
then its output ( this is the output which i need ),, will undergo FFT , running at sampling freq of 200 Mhz,,,
i know its going to alias.
Actually what i need .. is the aliased signal in the input bandwidth (dc to 100 ) to see the influence/attenuation of the anti-aliasing filter. I need to know the attenuation provided by the filter to the signal greater than Nyquist to meet a specific spec of its alias present in the bw( dc to 100)..
I hope i made myself clear
Hi Bandw W,
You could sample your 175 MHz signal at much higher frequency in order to represent the analogue signal (let's say at 1.75 GHz, if this is reasonable bandwith of your analogue domain signal path) - though it would be still digital. This signal you could filter with the "analog filter" representation for your simulation. The output would be still sampled at 1.75 GHz. That signal you could sample than with 200 MHz and do the rest of your processing.
If you want to work with real analogue signals I'd to refer to Star Strider's comment above.
Kind regards,
Robert
Thankyou :)

Sign in to comment.

Asked:

on 12 Aug 2019

Commented:

on 29 Aug 2019

Community Treasure Hunt

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

Start Hunting!