How to do frequency scaling in Frequency spectrum?

5 visualizaciones (últimos 30 días)
ong jia eek
ong jia eek el 23 de Oct. de 2019
disp('%=================================================%')
disp('%~~~~~~~~ `` Assalamualaikum `` ~~~~~~~~~%')
disp('% ```` Principle of Communication ( MATLAB ) ````%')
disp('')
disp('%`````````` *GROUP MEMBERS* ``````````%')
disp('%`` 1. ONG JIA EEK - A17MB0157 ``%')
disp('%`` 2. MAISARAAH YUZLAN - A17MB0078 ``%')
disp('%`` 3. NUR RAIHAN NAJAH BINTI TURIMAN - A17MB0137 ``%')
disp('')
disp('%=================================================%')
z=1
while z==1
A = menu('Please, select one! ','1.FULL AM','2.DSB-SC','3.SSB-SC','4.DSBSC & SSBSC SPECTRUM')
switch A
case 1
%>>>>>>>>>>>>>>>>>>>> 1.AM Modulation Simulation <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
close all;
%XXXXXXXXXXXXXXXXX modulating signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
disp('fc value must be larger than fm value.');
Em=input('Enter the value of amplitude modulation, Em ='); %amplitude of modulating signal
fm=input ('Enter the value of frequency modulation, fm ='); % Frequency of modulating signal
Tm=1/fm; % Time period of modulating signal
t=0:Tm/999:6*Tm; % Total time for modulated signal simulation (6 cycles will be displayed)
tm=0:Tm/999:6*Tm; % Total time for modulating signal simulation (6 cycles will be displayed)
ym=Em*cos(2*pi*fm*tm); % Equation of modulating signal
%XXXXXXXXXXXXXXXXXXXXX carrier signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
Ec=input('Enter the value of carrier signal amplitude, Ec =');% Amplitude of carrier signal
fc=input('Enter the value if carrier signal frequency, fc =');% Frequency of carrier signal
Tc=1/fc; % Time period of carrier signal
tc=0:Tc/999:6*Tc; % Total time for carrier signal simulation (6 cycles will be displayed)
yc=Ec*cos(2*pi*fc*tc);% Equation of carrier signal
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX AM Modulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
m=Em/Ec; % modulation index
y= Ec*(1+m*cos(2*pi*fm*t)).*cos(2*pi*fc*t); % Equation of Amplitude modulated signal
figure(1);
subplot(3,1,1);
plot(t,ym, 'g'), grid on;% Graphical representation of Modulating signal
title ( ' Modulating Signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');
subplot(3,1,2);
plot(t,yc, 'r'), grid on;% Graphical representation of carrier signal
title ( ' Carrier Signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');
subplot(3,1,3);
plot(t,y, 'm');% Graphical representation of AM signal
title ( ' Amplitude Modulated signal ');
xlabel ( ' time(sec) ');
ylabel (' Amplitude(volt) ');
grid on;
case 2
%>>>>>>>>>>>>>>>>>>>> 2.Double-Sideband Suppressed-Carrier Transmission (DSB-SC) <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
clear all;
Em = input ('Enter the message signal amplitude = ');
Ec = input ('Enter the carrier signal amplitude = ');
fm = input ('Enter the message frequency = ');
fc = input ('Enter the carrier frequency = ');
m = Em/Ec;
%T=input('enter the duration over which the signal is to be plotted= ')
%fs=input('enter the sampling frequency= ')
%t=0:T/fs:T;
% Representation of the Message Signal
t = 0:0.0001:0.05;
Message_Signal = Em*cos (2*pi*fm*t);
subplot (3,1,1);
plot (t,Message_Signal,'b');
xlabel ('Time');
ylabel ('Amplitude');
title ('Message Signal');
legend ('Message Signal');
% Representation of the Carrier Signal
Carrier_Signal = cos(2*pi*fc*t);
subplot (3,1,2);
plot (t,Carrier_Signal,'r');
xlabel ('Time');
ylabel ('Amplitude');
title ('Carrier Signal');
legend ('Carrier Signal');
% Representation of the DSBSC Signal
DSBSC_Signal=Ec*m.*cos (2*pi*fm*t).*cos (2*pi*fc*t)
subplot (3,1,3);
plot (t,DSBSC_Signal,'m');
xlabel ('Time');
ylabel ('Amplitude');
title ('Double Sideband Suppressed Carrier Wave');
legend ('DSB-SC Signal');
% Add title to the Overall Plot
ha = axes ('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'off');
text (0.5, 1,'\bf Analog Modulation Technique: Double Sideband Suppressed-Carrier Transmission (DSB-SC)','HorizontalAlignment','center','VerticalAlignment', 'top')
case 3
%>>>>>>>>>>>>>>>>>>>> 3.Single-Sideband Suppressed-Carrier Transmission (SSB-SC) <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
clear all;
close all;
fm=input('enter the message frequency fm = ')
fc=input('enter the carrier frequency fc = ')
T=input('enter the duration over which the signal is to be plotted = ')
fs=input('enter the sampling frequency = ')
t=0:T/fs:T;
%t = 0:0.0001:0.05;
%generation of Modulating and Carrier signals and their Hilbert Transforms
m=cos(2*pi*fm*t) %modulating signal
m1=cos(2*pi*fm*t-(pi/2)) %Hilbert signal
n=cos(2*pi*fc*t) %carrier signal
n1=cos(2*pi*fc*t-(pi/2)) %Hilbert signal
%%generation of Two AM-DSB-SC signals
M=m.*n;
M1=m1.*n1;
%%generation of AM-SSB-SC signal
ssb=M+M1; %modulated signal
subplot (3,1,1);
plot (t,m,'b');
xlabel ('Time');
ylabel ('Amplitude');
title ('Message Signal');
subplot (3,1,2);
plot (t,n,'r');
xlabel ('Time');
ylabel ('Amplitude');
title ('Carrier Signal');
subplot (3,1,3);
plot (t,ssb,'m');
xlabel ('Time');
ylabel ('Amplitude');
title ('Single Sideband Suppressed Carrier Wave');
ha = axes ('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'off');
text (0.5, 1,'\bf Analog Modulation Technique: Single Sideband Suppressed-Carrier Transmission (SSB-SC)','HorizontalAlignment','center','VerticalAlignment', 'top')
case 4
%>>>>>>>>>>>>>>>>>>>> 4.DSBSC AND SSBSC FREQUENCY SPECTRUM <<<<<<<<<<<<<<<<<<<<<<<<<<
clc;
close all;
%XXXXXXXXXXXXXXXXX modulating signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
disp('fc value must be larger than fm value.');
Em=input('Enter the value of amplitude modulation, Em ='); %amplitude of modulating signal
fm=input ('Enter the value of frequency modulation, fm ='); % Frequency of modulating signal
Tm=1/fm; % Time period of modulating signal
t=0:Tm/999:6*Tm; % Total time for modulated signal simulation (6 cycles will be displayed)
tm=0:Tm/999:6*Tm; % Total time for modulating signal simulation (6 cycles will be displayed)
ym=Em*cos(2*pi*fm*tm); % Equation of modulating signal
%XXXXXXXXXXXXXXXXXXXXX carrier signal generation XXXXXXXXXXXXXXXXXXXXXXXXXX
Ec=input('Enter the value of carrier signal amplitude, Ec =');% Amplitude of carrier signal
fc=input('Enter the value if carrier signal frequency, fc =');% Frequency of carrier signal
Tc=1/fc; % Time period of carrier signal
tc=0:Tc/999:6*Tc; % Total time for carrier signal simulation (6 cycles will be displayed)
yc=Ec*cos(2*pi*fc*tc);% Equation of carrier signal
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX AM Modulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
m=Em/Ec; % modulation index
y= Ec*(1+m*cos(2*pi*fm*t)).*cos(2*pi*fc*t); % Equation of Amplitude modulated signal
%XXXXXXXXXXXXXXXXXXXXXXX Frequency Spectrum Of Modulated Signal XXXXXXXXXXX
N = length(y); %Number of samples
fs= 2*fc; % Sample frequency (Hz)
f =(0:N-1)*(fs/N); %frequency range(Hz)
% Double-sided amplitude spectrum
figure(2);
subplot(3,1,1);
Amp = abs(fftshift(fft(y))); %Amplitude of spectrum
plot(f, Amp, 'g')
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Double-sideband frequency spectrum (Hertz)');
% Single-sided amplitude spectrum with frequency axis in Hertz
subplot(3,1,2);
Amp = abs(fft(y)); %Amplitude of modulated signal in Frequency spectrum
plot(f, Amp,'b');
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Single-sideband frequency spectrum (Hertz)');
%>>>>>>>>>>>>>>>>>>>>>> end of program <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
end
B = menu('Do you want to continue?','1.Yes','2.No');
switch B
case 1
z=1;
case 2
z=0;
end
end
As above is my code, I wish to obtain the correct frequency spectrum code for ssb and dsb but unfortunately, I couldn't get it.

Respuestas (0)

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by