Демодуляция зашумленного FM-сигнала - PullRequest
1 голос
/ 02 апреля 2020

Мне любопытно, почему я не получаю правильный демодулированный сигнал на выходе этого кода:

%% (1) - generation of white gaussian noise
t = -10:.01:10; %definition of time from -10 to 10 

%(a)
pa = 2*10^-3;                            %power of white noise signal 2mW
%(b)
pb = 20*10^-3;                           %power of white noise signal 20mW

a = genWGN(pa,t,1);
z = genWGN(pb,t,1);

%% (2) - plot of the FM signal in frequency and time domains

fc = 1575;                              % Frequency of carrier
ts = 1/(fc*2);                            %sampling rate of the signal
t = 0:ts:0.2;

msg = .5*sin(2*pi*5*t);                 % message

% modulation
kf = 90;
m_int = kf*ts*cumsum(msg);              % integration
fm = cos(2*fc*pi*t + m_int);            % fm = cos(2*pi*fc*t + integral(msg))

%plotting signals in time domain
figure('units','normalized','outerposition',[0 0 1 1]);
subplot(4,1,1);
plot(t,msg);
title('Message Signal');
xlabel('time(s)');
ylabel('m(t)');
grid
subplot(4,1,2);
plot(t,fm);
title('FM Signal');
xlabel('time(s)');
ylabel('m(t)');
grid

% frequency response of m(t) and modulated m(t)
fl = length(t);
fl = 2^ceil(log2(fl));
f = (-fl/2:fl/2-1)/(fl*ts);
mF = fftshift(fft(msg,fl));             % Frequency Response of Message Signal

fmF = fftshift(fft(fm,fl));             % Frequency Response of FM Signal

%plotting magnitude of the frequency response
subplot(4,1,3);
plot(f,abs(mF));
title('Message Signal Frequency Response');
xlabel('frequency(Hz)');
ylabel('M(f)');
subplot(4,1,4);
plot(f,abs(fmF));
title('FM Signal Frequency Response');
xlabel('frequency(Hz)');
ylabel('M(f)');

%% (3)
t = 0:ts:.2;
%generates the WGN at an equal length of the fm signal
z = (genWGN(pb,t,0)).';

%signal with additive noise in it
r = z + fm;

%demodulation through differentiator
dem = diff(r);       
dem = [0,dem];
rect_dem = abs(dem);

%low pass filter    
[b, a] = butter(4, fc/(1/ts)); %4th order lowpass butterworth filter
rec = filter(b, a, rect_dem)

%plotting signals in time domain
figure();
subplot(3,1,1)
plot(t,r);
title('Message Signal with Noise');
xlabel('time(s)');
ylabel('m(t)');
subplot(3,1,2)
plot(t,rect_dem)
title('Demodulated Message');
xlabel('time(s)');
ylabel('m(t)');
subplot(3,1,3)
plot(t,rec)
title('Filtered Message');
xlabel('time(s)');
ylabel('m(t)');
grid

%% Function Definitions
function y = genWGN(p,t,display)

    sigma = sqrt(p); %the equation for sigma is the sqrt of the power
    newsigma = sigma;

    for i = 1:length(t)
        sigma(i) = newsigma;
    end

    y = newsigma.*randn(length(t),1); %generate random signal in respect to the variance using the normally distributed random number

    distro = 1./(sigma.*sqrt(2.*pi)).*exp(-1/2.*(t./sigma).^2); %generation of the random distribution, being gaussian white noise, there is no mean

    if display == 1     
        figure
        subplot(2,1,1)
        plot(t,y)
        hold on
        grid on
        title("Gaussian White Noise: " + p + " Watts")
        ylim([-.6 .6])
        xlim([0 10])
        xlabel("time(s)")
        ylabel("n(t)")
        subplot(2,1,2);
        plot(t, distro)
        title("Normal Distribution: " + p + " Watts")
        xlim([-1 1])
        hold off
    end
end

Я попытался настроить время выборки, и с очень низким временем выборки я получаю FM-сигнал, который выглядит так, как он должен выглядеть. Когда я сэмплирую с частотой дискретизации Найквиста, я получаю модулированный сигнал, который выглядит как AM-сигнал?

Выходные графики модулированного сигнала на Найквисте:

MATLAB Plots

Я сделал какие-либо ошибки?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...