Amplitude modulation with a square wave as the message signal

조회 수: 3 (최근 30일)
S
S 2015년 3월 18일
답변: S 2015년 3월 19일
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