Você está na página 1de 40

INTRODUCTION TO MATLAB. 1.

GENERATION OF BASIC SIGNALS USING MATLAB

AIM : To generate basic signals like unit impulse, unit step, unit ramp signal and Exponential signals. Requirements : Computer with MATLAB software % (a). Program for the generation of UNIT impulse signal clc; close all; clear all; f=-2:1:2; y=[zeros(1,2),ones(1,1),zeros(1,2)] figure(1) subplot(2,2,1); stem(f,y); title('unit impulse');

% (b). Program for the generation of UNIT step signal n=input('enter the n value'); f=0:1:n-1; y=ones(1,n); figure(1) subplot(2,2,2); stem(f,y); title('unit step'); % (c).Program for the generation of unit RAMP signal

n=input('enter the n value'); f=0:n; y=0:n; figure(1) subplot(2,2,3); stem(f,f); title('unit ramp'); % (d).Program for the generation of Exponential signal n=input('the length of i/p sequency'); f=0:n a=input('enter the a value'); y=exp(a*f); figure(1)

subplot(2,2,4); stem(f,y); title('unit exponential') OUTPUT: y= 0 0 1 0 0

Enter the n value 6 Enter the n value 7 The length of i/p value 5 f= 0 1 2 3 4 5 6

Enter the a value 2

unit impulse 1 0.8 0.6 0.4 0.2 0 -2 -1 0 unit ramp 6 4 3 1 2 1 0.8 0.6 0.4 0.2 0 0 2

unit step

unit exponential

y-axis
0 2 4 6

2 1 0

2 x-axis

FIG: Basic signals like unit impulse, unit step, unit ramp signal and Exponential signals

Result: Hence we generate basic signals like unit impulse, unit step, unit ramp signal and Exponential signals.

2. AMPLITUDE MODULATION & DEMODULATION AIM: To generate the amplitude modulated signal and also calculate the modulation index Requirements : Computer with MATLAB software. Program: for the generation of amplitude modulated signal. %amplitude modulation clc; clear all; close all; f=500; fc=5000;

fs=8*fc; ts=1/fs; t=0:ts:8/f; m=cos(2*pi*f*t); c=cos(2*pi*fc*t); s=c+m.*c; s1=s.*c; subplot(4,1,1); plot(t,m); xlabel('time'); ylabel('magnitude'); title('message signal'); subplot(4,1,2); plot(t,c); xlabel('time');

ylabel('magnitude'); title('carrier signal'); subplot(4,1,3); plot(t,s); xlabel('time'); ylabel('magnitude'); title('Amplitude modulated signal'); d=s.*c; subplot(4,1,4); plot(t,d); xlabel('time'); ylabel('magnitude'); title('demoduated signal')

Fig: Amplitude Modulation Result: Hence we generate the amplitude modulated signal and acalculated the modulation index

3. SINGLE SIDEBAND SYSTEM AIM: To study the generation of single side band (SSB) amplitude modulation and de- modulation. Requirements : Computer with MATLAB software. Program: %single side band system clc; clear all; close all; Ac=1; f=500; fc=5000; fs=8*fc;

ts=1/fs; t=0:ts:8/f; m=cos(2*pi*f*t); c=cos(2*pi*fc*t); s1=Ac/2*(m.*chilbert(m).*sin(2*pi*fc*t)); s2=Ac/2*(m.*c+hilbert(m).*sin(2*pi*fc *t)); subplot(5,1,1); plot(t,m); xlabel('time'); ylabel('magnitude'); title('message signal'); subplot(5,1,2); plot(t,c);

xlabel('time'); ylabel('magnitude'); title('carrier signal'); subplot(5,1,3); plot(t,s1); xlabel('time'); ylabel('magnitude'); title('SSB with Upper sideband signal'); d=s1.*c; subplot(5,1,4); plot(t,s2); xlabel('time'); ylabel('magnitude');

title('SSB with lowerside band signal'); subplot(5,1,5); plot(t,d); xlabel('time'); ylabel('magnitude'); title('demodulated signal');

Fig: SSB SYSTEM

Result: Hence we generated single side band (SSB) amplitude modulation and de- modulation.

4.DOUBLE SIDE BAND SYSTEM AIM: To obtain the output characteristics of a Double side band- Suppressed carrier AM modulation and demodulation Requirements : Computer with MATLAB software. Program: %double side band suppressed carrier clc; clear all; close all; f=500; fc=5000;

fs=8*fc; ts=1/fs; t=0:ts:8/f; m=cos(2*pi*f*t); c=cos(2*pi*fc*t); s=m.*c; subplot(4,1,1); plot(t,m); xlabel('time'); ylabel('magnitude'); title('message signal'); subplot(4,1,2); plot(t,c); xlabel('time'); ylabel('magnitude');

title('carrier signal'); subplot(4,1,3); plot(t,s); xlabel('time'); ylabel('magnitude'); title('DSBSC signal'); d=s.*c; subplot(4,1,4); plot(t,d); xlabel('time'); ylabel('magnitude'); title('demodulated signal');

Fig: DSB SYSTEM

Result: Hence we obtained the output characteristics of a Double side band- Suppressed carrier AM modulation and demodulation

5.FREQUENCY MODULATION Aim: To generate a frequency modulation and demodulation signal using Matlab Source. Requirements : Computer with MATLAB software Program: %frequency mopdulation clc; clear all; close all; ac=5; f=500; fc=5000; fs=8*fc;

ts=1/fs; t=0:ts:8/f; m=cos(2*pi*f*t); c=cos(2*pi*fc*t); s=ac*cos(2*pi*fc*t+5*sin(2*pi*f*t)); subplot(3,1,1); plot(t,m); xlabel('time'); ylabel('magnitude'); title('message signal'); subplot(3,1,2); plot(t,c); xlabel('time'); ylabel('magnitude'); title('carrier signal');

subplot(3,1,3); plot(t,s); xlabel('time'); ylabel('magnitude'); title('FM signal');

Fig: FREQUENCY MODULATION & DE MODULATION Result: Hence we generate a frequency modulation and

demodulation signal using Matlab Source.

6. PULSE WIDTH MODULATION AIM: To construct pulse width modulation circuit and observe modulation and demodulation. Requirements : Computer with MATLAB software. Program: %pulse width modulation clc; clear all; close all; fc=1000; fs=4*fc; ts=1/fs; f=200;

t=0:ts:5/f; x=.4*sin(2*pi*f*t)+.5; s=modulate(x,fc,fs,'pwm'); subplot(3,1,1); plot(x); subplot(3,1,2); plot(s); d=demod(s,fc,fs,'pwm'); subplot(3,1,3); plot(d);

Fig: PULSE WIDTH MODULATION

Result: Hence we constructed pulse width modulation circuit and observed modulation and demodulation.

7. PULSE AMPLITUDE MODUATION AIM: To generate a Pulse amplitude modulated signal and also demodulate the original signal. Requirements : Computer with MATLAB software. Program: %pulse amplitude modulation clc; clear all; close all; f=500; fs=12*f;

ts=1/fs; t=0:ts:5/f; x=0.4*cos(2*pi*f*t)+.5; c=square(2*pi*f*t,0.5); subplot(2,1,1); plot(x); subplot(2,1,2); s=x.*c; stem(abs(s));

Fig: Pulse Amplitude Modulation Result: Hence we generate a Pulse amplitude modulated signal and also demodulate the original signal.

8. PULSE POSITION MODULATION

AIM: To generate a Pulse position modulated/demodulated signal using Matlab source Requirements : Computer with MATLAB software. Program: %pulse position mosulation clc; clear all; close all; fc=1000; fs=4*fc; ts=1/fs; f=200; t=0:ts:5/f; x=.4*sin(2*pi*f*t)+.5;

s=modulate(x,fc,fs,'ppm',0.6); subplot(3,1,1); plot(x); subplot(3,1,2); plot(s); d=demod(s,fc,fs,'ppm',0.6); subplot(3,1,3); plot(d);

Fig: PULSE POSITION MODUALTION

Result: Hence we generated a Pulse position modulated/demodulated signal using Matlab source.

9. SAMPLING THEOREM AIM: To sample the given input signal at different sampling rates and reconstruct the original signal by passing through a low pass filter. Requirements : Computer with MATLAB software. Program: % sampling theorem clc; clear all; close all; fm=100; fs=600; ts=1/fs;

t=0:ts:10/fm; x=sin(2*pi*fm*t); subplot(4,1,1); stem(x); fx=fft(x); xr=ifft(fx); subplot(4,1,2); stem(xr); fm2=400; x2=sin(2*pi*fm2*t); subplot(4,1,3); stem(t,x2); fx1=fft(x2); xr1=ifft(fx1); subplot(4,1,4);

stem(xr1);

Fig: SAMPLING THEOREM

RESULT: Hence sampling theorem is verified.

Você também pode gostar