matlab仿真源代码
源代码在线查看: amtf.m
%Amplitude Modulation with multitone signal and its spectrum analysis
%Show the time domain and frquency domain representation of DSB-AM and
%DSB-SC modulations
%Saurav R Tuldhar, DOECE/PC/IOE/TU 14th October 2005
%Suggestions @->> 059bex438@ioe.edu.np
N = 1024; %N point FFT N>fc to avoid freq domain aliasing
fs = 4096; % sample frequency
t = (0:N-1)/fs;
fc = 600; %Carrier Frequency
fm1 = 20; %Three message signal frequencies
fm2 = 80;
fm3 = 40;
Ec = 20; %Carrier Amplitude
Em1 = 5; %Three message signal amplitudes
Em2 = 5;
Em3 = 5;
% Try changing the message and carrier amplitudes to see the effect in
% DSB-AM modulation
%---------Double SideBand Full Carrier Modulation (DSB-FC(AM))
A = Ec + Em1*sin(2*pi*fm1*t) + Em2*sin(2*pi*fm2*t) + Em3*sin(2*pi*fm3*t); %Envelope/eliminate the carrier amplitude
m = A.*[sin(2*pi*fc*t)]; %to convert DSB-AM to DSB-SC
Mf = 2/N*abs(fft(m,N));
f = fs * (0 : N/2) / N; %Since the fft result is symmetrical, only the positive half is sufficient for spectral representation
close all;
figure('Name','Time/Fequency domain representations of DSB-AM signals');
subplot(2,1,1); %Time domain plot
plot(t(1:N/2),m(1:N/2),t(1:N/2),A(1:N/2),'r',t(1:N/2),-A(1:N/2),'r');
title('Time Domain Representation');
xlabel('Time'); ylabel('Modulated signal');
subplot(2,1,2); %Frequency Domain Plot
plot(f(1:256),Mf(1:256));
title('Frequency Domain Representation');
xlabel('Frequency (Hz)'); ylabel('Spectral Magnitude');
%----------Double SideBand Suppressed Carrier DSB-SC----------
A = Em1*sin(2*pi*fm1*t) + Em2*sin(2*pi*fm2*t) + Em3*sin(2*pi*fm3*t); %Envelope/eliminate the carrier amplitude
m = A.*[sin(2*pi*fc*t)]; %to convert DSB-AM to DSB-SC
Mf = 2/N*abs(fft(m,N));
figure('Name','Time/Fequency domain representations of DSB-SC signals');
subplot(2,1,1); %Time domain plot
plot(t(1:N/2),m(1:N/2),t(1:N/2),A(1:N/2),'r',t(1:N/2),-A(1:N/2),'r');
title('Time Domain Representation');
xlabel('Time'); ylabel('Modulated signal');
subplot(2,1,2); %Frequency Domain Plot
plot(f(1:256),Mf(1:256));
title('Frequency Domain Representation');
xlabel('Frequency (Hz)'); ylabel('Spectral Magnitude');
text(15,60,'Carrier');
%--------------------------------------------------------------------