0% found this document useful (0 votes)
133 views

MATLAB Code For Amplitude Modulation

The document contains MATLAB code examples for amplitude modulation, amplitude demodulation, and frequency modulation. The amplitude modulation code generates an amplitude modulated signal and plots its spectrum. The amplitude demodulation code demodulates an AM signal back to the original signal and plots both. The frequency modulation code generates a frequency modulated signal from a message signal, demodulates it using a differentiator, filters it, takes the FFT of the signals, and plots the original message signal.

Uploaded by

kamlesh chauhan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

MATLAB Code For Amplitude Modulation

The document contains MATLAB code examples for amplitude modulation, amplitude demodulation, and frequency modulation. The amplitude modulation code generates an amplitude modulated signal and plots its spectrum. The amplitude demodulation code demodulates an AM signal back to the original signal and plots both. The frequency modulation code generates a frequency modulated signal from a message signal, demodulates it using a differentiator, filters it, takes the FFT of the signals, and plots the original message signal.

Uploaded by

kamlesh chauhan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MATLAB code for Amplitude Modulation

fs = 100;

t = (0:1/fs:100)';

fc = 10;

x = sin(2*pi*t);

ydouble = ammod(x,fc,fs);

ysingle = ssbmod(x,fc,fs);

sa = dsp.SpectrumAnalyzer('SampleRate',fs, ...

'PlotAsTwoSidedSpectrum',false, ...

'YLimits',[-60 40]);

step(sa,ydouble)
MATLAB code for Amplitude Demodulation

fc = 10e3;

fs = 80e3;

t = (0:1/fs:0.01)';

s = sin(2*pi*300*t)+2*sin(2*pi*600*t);

[num,den] = butter(10,fc*2/fs);

y = ammod(s,fc,fs);

z = amdemod(y,fc,fs,0,0,num,den);

plot(t,s,'c',t,z,'b--')

legend('Original Signal','Demodulated Signal')

xlabel('Time (s)')

ylabel
MATLAB code for Frequency Modulation

clear all;

close all;

clc;

%% Frequency MODULATION of Triangular Signal

t = -0.04:1.e-4:0.04;

Ta = 0.01;

fc = 200;

msg = msg1(t,Ta);

%% MODULATION

kf = 160*pi;

m_int = kf*1.e-4*cumsum(msg);

fm = cos(2*fc*pi*t + m_int);

%% DEMODULATION (Using Differentiator)

dem = diff(fm);

dem = [0,dem];

rect_dem = abs(dem);

%% Filtering out High Frequencies

N = 80;

Wn = 1.e-2;

a = fir1(N,Wn);

b = 1;

rec = filter(a,b,rect_dem);
%% Finding frequency Response of Signals

fl = length(t);

fl = 2^ceil(log2(fl));

f = (-fl/2:fl/2-1)/(fl*1.e-4);

mF = fftshift(fft(msg,fl));

fmF = fftshift(fft(fm,fl));

rect_demF = fftshift(fft(rect_dem,fl));

recF = fftshift(fft(rec,fl));

%% Plotting signal in time domain

figure;

subplot(2,1,1);

plot(t,msg);

title('Message Signal');

xlabel('{\it t} (sec)');

ylabel('m(t)');

grid;
OUTPUT for frequency Modulation

You might also like