Amplitude modulation with a square wave as the message signal
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!