Matlab Codes
Matlab Codes
Matlab Codes
AM is a method of
transmitting signals, such as sound or digital information, in which the
amplitude of carrier wave is changed according to the message signal. AM is
widely used in electronic communication field. The plotting of AM signal using
MATLAB is very easy.
Here we are simply adding the carrier amplitude with message signal to obtain
AM signal, then the instantaneous amplitude of carrier gets altered with respect
to modulating signal. Thus the carrier amplitude varies according to the base
band signal (message signal). The MATLAB code is shown below, the uses of
particular code is also given in commented form (%Comment field). The program
is capable of accepting two input frequencies and modulation index from the
keyboard.
MATLAB Codes
clc;
clear all;
close all;
t=0:0.001:1;
set(0,defaultlinelinewidth,2);
A=5;%Amplitude of signal
fm=input(Message frequency=);%Accepting input value
fc=input(Carrier frequency=);%Accepting input value (f2>f1)
Also see:
MATLAB Codes
clc;
clear all;
close all;
fm=input('Message Frequency=');
fc=input('Carrier Frequency=');
mi=input('Modulation Index=');
t=0:0.0001:0.1;
m=sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
c=sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,c);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;
y=sin(2*pi*fc*t+(mi.*sin(2*pi*fm*t)));%Frequency changing w.r.t Message
subplot(3,1,3);
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('FM Signal');
grid on;
plot(t,x);
xlabel('time');
ylabel('Amplitude');
title('Carrier');
grid on;
u=square(2*pi*f2*t);%Message signal
subplot(3,1,2);
plot(t,u);
xlabel('time');
ylabel('Amplitude');
title('Message Signal');
grid on;
v=x.*u;%Sine wave multiplied with square wave
subplot(3,1,3);
plot(t,v);
axis([0 1 -6 6]);
xlabel('t');
ylabel('y');
title('PSK');
grid on;
MATLAB code is also given as comments (%Comment field). The given MATLAB
program accepts two input frequencies from the user.