From: mayowa on
Hi Guys

I am trying to simulate NBFM modulation and demodulation in MATLAB. I am not getting it quite right. The signal x that I am getting is waaaaaaaaaay off. I need some hints. Thanks

-----------------------
clear all
clc

%Carrier Frequency 1Mhz
fc = 1E6;
fs = 4*fc;
Ts = 1/fs; %Sampling time

%Simulation Time
T = 1E-4;

% time
t = 0:Ts:T;

%Generate signal
m = cos(2*pi*5000*t);

%Amplitude Modulation
omegac = 2*pi*fc;

%Modulation index
kp = 0.1*pi/max(m);
m_n = kp*m;
s = cos(omegac*t + kp*m);

%Receiver
%hardlimit and do AM demodulation
%hardlimit
Sh = sign(s);

%pass through band pass filter
cutoff = [.3 .7];
[b, a] = butter(8, cutoff, 'bandpass'); %design butterworth low pass filter
Sig = filter(b,a, Sh); %filter demodulation signal

%use conventional AM
R = Sig.* cos(omegac*t);
[b, a] = butter(8, 0.5); %design butterworth low pass filter
x = filter(b, a, R); %filter demodulation signal

figure(1)
%spectral of message

Nf = 1024; % Number of points in FFT, for faster computation
f = (0:Nf-1)'/Nf*fs/4; % Frequencies in FFT
sumsigf = fft(m_n, Nf);
plot(f, abs(fftshift(sumsigf)))
title('Spectrum of PM Signal')
xlabel('Frequency (Hz)')

figure(3)
%spectral of message
Nf = 1024; % Number of points in FFT, for faster computation
f = (0:Nf-1)'/Nf*fs/4; % Frequencies in FFT
S = fft(s, Nf);
plot(f, abs(fftshift(S)))
title('Spectrum of Signal')
xlabel('Frequency (Hz)')

figure(4)
%spectral of message
Nf = 1024; % Number of points in FFT, for faster computation
f = (0:Nf-1)'/Nf*fs/4; % Frequencies in FFT
Lf = fft(Sh, Nf);
plot(f, abs(fftshift(Lf)))
title('Spectrum of Signal after bandlimiting')
xlabel('Frequency (Hz)')

% figure(2)
% subplot(3,1,1)
% plot(t, diff_sig)
% xlabel('t')
% ylabel('m_1(t)')
% title('Sent Message')
%
% subplot(3,1,2)
% plot(t, PM_signal)
% xlabel('t')
% ylabel('m_1(t)')
% title('Pulse Modulated Message')

% subplot(3,1,3)
% plot(t,xfilt1)
% xlabel('t')
% ylabel('m_1(t)')
% title('Demodulated Message')
 | 
Pages: 1
Prev: OutputEmptyFcn
Next: ScatterHist m file