Amplitude modulation with a square wave as the message signal

12 次查看(过去 30 天)
Dear all,
Hi,
I have written some codes which produce the output I want,as follow
{
clc;
clear all;
N = 1024; %N point FFT N>fc to avoid freq domain aliasing
fs = 4096; % sample frequency
t = (0:N-1)/fs;
fc = 280e6; %Carrier Frequency
fm = 100; %Three message signal frequencies
Ec = 20; %Carrier Amplitude
Em = 5;
A = Ec + Em*sin(2*pi*fm*t);
n=Ec*sin(2*pi*fc*t);
m=1+Em/2.*square(2*pi*fm*t)+(Em/2);
subplot(2,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
subplot(2,1,2);
plot(t,n);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;
k=n.*m;
k( k<0 )=0;
Mf = 2/N*abs(fft(k,N));
f = fs * (0 : N/2) / N;
close all;
figure('Name','Time/Fequency domain representations of DSB-AM signals');
subplot(3,1,1); %Time domain plot
plot(t(1:N/2),k(1:N/2),t(1:N/2),k(1:N/2),'r',t(1:N/2),-k(1:N/2),'r');
title('Time Domain Representation');
xlabel('Time'); ylabel('Modulated signal');
subplot(3,1,2); %Time domain plot
plot(t(1:N/2),k(1:N/2),t(1:N/2),k(1:N/2),'r');
title('Time Domain Representation');
xlabel('Time'); ylabel('Modulated signal');
subplot(3,1,3); %Frequency Domain Plot
plot(f(1:256),Mf(1:256));
title('Frequency Domain Representation');
xlabel('Frequency (Hz)'); ylabel('Spectral Magnitude');
}
Now I want to replace 'm' signal with the following code,
{
t = 0:.1:20;
y = zeros(20,length(t));
x = zeros(size(t));
for k = 1:2:39
x = x + sin(k*t)/k;
y((k+1)/2,:) = x;
end
plot(t,y);
title('The building of a square wave')
}
But,cant squeeze it in correctly. I'm tired of looking at it now, would you please help me on that. I appreciate your help.
BW, S.

采纳的回答

S
S 2015-3-19
It's been done!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by