- 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 ).
- I'm not sure that the cut-off frequency Fc/Fs is correct. I need to think about it a bit more.
Incorrectly applying low pass filter to discrete data (Modulation)
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
0 Kommentare
Akzeptierte Antwort
Rick Rosson
am 29 Aug. 2011
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:
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
Weitere Antworten (2)
Rick Rosson
am 29 Aug. 2011
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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matched Filter and Ambiguity Function finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!