フィルターのクリア

Incorrectly applying low pass filter to discrete data (Modulation)

2 ビュー (過去 30 日間)
Rudolf Hoehler
Rudolf Hoehler 2011 年 8 月 29 日
Hi there,
I have written a program that correctly modulates a signal, and now needs to demodulate it. The code can be found below. Just running it directly should make the problem clear immediately. :)
During the last step of the demodulation process I need to apply a low pass filter to get rid of high frequency components. When I do apply the filter, it treats the data as an image and nicely smooths out the high frequency components of the curve. :) This is not what i need. I need to apply a filter that cuts off in the KHz range, and I need the two peaks at 2 Mhz to disappear. Can some one please point me in the right direction on how to achieve the filtering?
Any help would greatly be appreciated,
Thanks for your time,
Rudolf
% Initialize:
close all;
clear all;
clc;
% Carrier specification:
Fc = 1e6; % hertz
Ac = 1; % amplitude
% Message specification:
Fm = 5000; % hertz
Am = 100; % amplitude
% Sampling Rate:
Fs = 10*Fc; % samples per second
dt = 1/Fs; % seconds per sample
% Time domain:
StartTime = 0.00; % seconds
StopTime = 0.01;
t = StartTime:dt:StopTime-dt;
% Test signals:
c = Ac*cos(2*pi*Fc*t);
m = Am*cos(2*pi*Fm*t);
plot(t,m);
% Plot annotations.
grid
xlabel('Time')
ylabel('Amplitude')
title('Message Signal m(t) @ 5KHz')
%Create PeriodoGram object
h = spectrum.periodogram;
opts = msspectrumopts(h,m);
opts.NFFT = 65536;
opts.Fs = Fs;
opts.CenterDC = true;
msspectrum(h,m,opts)
%Hilbert Filter
m_Hilbert = hilbert(m);
msspectrum(h,m_Hilbert,opts)
%Modulate%
m_HilbertMod = m_Hilbert.*exp(j*2*pi*Fc*t);
msspectrum(h,real(m_HilbertMod),opts)
%DeModulate by UP modulating singnal to 2 KHz and recovering 5Khz band
m_HilbertMod_demod = m_HilbertMod.*c ;
%m_HilbertMod_demod = m_HilbertMod.*exp(j*w_c*t) ;
%
%-=PROBLEM ENTERS HERE=-
%Plot Spectrum of UP converted wave:
subplot(2,1,1)
msspectrum(h,real(m_HilbertMod_demod),opts)
%Create Filter
[num,den] = butter(12, (Fc/Fs), 'low','s' ) ;
%Filter m_HilbertMod_demod
m_HilbertMod_demod_filtered = filter(num,den,m_HilbertMod_demod);
%Plot filtered results.
subplot(2,1,2)
msspectrum(h,real(m_HilbertMod_demod_filtered),opts)

採用された回答

Rick Rosson
Rick Rosson 2011 年 8 月 29 日
I am pretty sure that the problem is with this line of code:
[num,den] = butter(12, (Fc/Fs), 'low','s' ) ;
There are two issues:
  1. The 's' option specifies the design of an analog filter, but you should be designing a digital filter in this case. To fix this issue, simply delete the ,'s' prior to the ).
  2. I'm not sure that the cut-off frequency Fc/Fs is correct. I need to think about it a bit more.
I would recommend trying the following:
[num,den] = butter(12, (Fc/Fs), 'low' ) ;
fvtool(num,den);
to see if the filter is designed correctly. For more information:
>> doc fvtool
HTH.
Rick
  1 件のコメント
Rudolf Hoehler
Rudolf Hoehler 2011 年 8 月 29 日
I had convinced myself that because I'm working in the discrete domain
the filter should be digital! :) Perfect! It works!
Thanks Rick, much appreciated.
Regards,
Rudolf

サインインしてコメントする。

その他の回答 (2 件)

Rick Rosson
Rick Rosson 2011 年 8 月 29 日
Hi Rudolf,
Before looking at the filtering part, there are a number of issues in how the code sets up the test signals. In particular, the code is not consistent in how it deals with sampling rates (in samples per second), sampling times (seconds per sample), frequency (in hertz or cycles per second), and angular frequency (in radians per second).
In addition, the code includes a variable called wavelength_m that really does not represent a wavelength in the technical sense of the term.
I would strongly recommend spending some time and effort cleaning up the first half of the code (prior to the first plot function) to ensure that the test signals are correct and as intended.
Here is what I would recommend:
% Initialize:
close all;
clear all;
clc;
% Carrier specification:
Fc = 1e6; % hertz
Ac = 1; % amplitude
% Message specification:
Fm = 5000; % hertz
Am = 100; % amplitude
% Sampling Rate:
Fs = 10*Fc; % samples per second
dt = 1/Fs; % seconds per sample
% Time domain:
StartTime = 0.00; % seconds
StopTime = 0.01;
t = StartTime:dt:StopTime-dt;
% Test signals:
c = Ac*cos(2*pi*Fc*t);
m = Am*cos(2*pi*Fm*t);
Then you can go on from there.
I think you will find that these changes alone may eliminate at least some of the issues, and will certainly make it easier to find any others that remain.
HTH.
Rick

Rudolf Hoehler
Rudolf Hoehler 2011 年 8 月 29 日
Hi Rick,
Sorry for the garbled code. :) I have implemented your recommendations. Thank you very much for taking the time to type out the initialization it's made my own code a lot clearer to myself...
And increasing the number of periods that the wave runs for has increased the clarity of my spectrum plots.
But I still have the filter issue.
Again, sorry for the garbled code.
Rudolf

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by