38
1 EXPERIMENT-1 AIM - Write a Matlab code to generate sine, cosine, exponential, unit step, unit impulse and unit ramp function. THEORY- A signal as referred to in communication systems , signal processing , and electrical engineering "is a function that conveys information about the behavior or attributes of some phenomenon".There are different types of signals like: 1.Sine wave- The sine wave or sinusoid is a mathematical curve that describes a smooth repetitive oscillatio n.The signal repeats itself after a period of 2pi. Its most basic form as a function of time (t) is: The sine function attains maximum value of 1 at angles (n+i)pi/2 and value 0 at n*pi. 2.Cosine wave- A cosine wave is a signal waveform with a shape identical to that of a sine wave , except each point on the cosine wave occurs exactly 1/4 cycle earlier than the corresponding point on the sine wave. A cosine wave and its corresponding sine wave have the same frequency, but the cosine wave leads the sine wave by 90 degrees of phase . 3.Exponential signal -A real exponential signal is defined as

matlab file

Embed Size (px)

DESCRIPTION

matlab file

Citation preview

Page 1: matlab file

1

EXPERIMENT-1

AIM - Write a Matlab code to generate sine, cosine, exponential, unit step, unit impulse and unit ramp function.

THEORY- A signal as referred to in communication systems, signal processing, and electrical engineering "is a function that conveys information about the behavior or attributes of some phenomenon".There are different types of signals like:

1.Sine wave-The sine wave or sinusoid is a mathematical curve that describes a smooth repetitive oscillation.The signal repeats itself after a period of 2pi. Its most basic form as a function of time (t) is:

The sine function attains maximum value of 1 at angles (n+i)pi/2 and value 0 at n*pi.

2.Cosine wave- A cosine wave is a signal waveform with a shape identical to that of a sine wave , except each point on the cosine wave occurs exactly 1/4 cycle earlier than the corresponding point on the sine wave. A cosine wave and its corresponding sine wave have the same frequency, but the cosine wave leads the sine wave by 90 degrees of phase .

3.Exponential signal-A real exponential signal is defined as

                                                                      Where both "A" and "σ" are real. Depending on the value of "σ" the signals will be different. If "σ" is positive the signal x(t) is a growing exponential and if "σ" is negative then the signal x(t) is a decaying exponential. For σ=0, signal x(t) will be constant.

Page 2: matlab file

2

   4.Impulse signal-The Dirac delta function or unit impulse or often referred to as the delta function, is the function that defines the idea of a unit impulse in continuous-time. Informally, this function is one that is infinitesimally narrow, infinitely tall, yet integrates to one. Perhaps the simplest way to visualize this as a rectangular pulse from a -D/2 to a +D/2 with a height of 1/D. As we take the limit of this setup as D approaches 0, we see that the width tends to zero and the height tends to infinity as the total area remains constant at one.The impulse function is often written as 

If the magnitude at 0 is 1 unit then the function is termed as unit impulse function.

5.Unit step function-The Heaviside step function, or the unit step function, usually denoted by H (but sometimes u or θ), is adiscontinuous function whose value is zero for negative argument and one for positive argument.

An alternative form of the unit step, as a function of a discrete variable n:

Page 3: matlab file

3

6.Ramp function-The ramp function ( ) may be defined analytically in several ways. Possible definition is:

It has a value 0 for x<0 and a value r(x)=x for positive x. Thus forming a line with slope 1 for x>0.

CODE:

t= [0:pi/12:2*pi];m=[-20:1:20];j=[-1:0.1:1];l=[-20:20];x=sin(t);y=cos(t);e=exp(j);k=1;for i= -20:20; if i<0 r(k)=0; else r(k)=i; end k=k+1;endu=[zeros(1,20),ones(1,1),ones(1,20)]d=[zeros(1,20),ones(1,1),zeros(1,20)] subplot(3,2,1) plot(t,x) title('sine curve') subplot(3,2,2) plot(t,y) title('cosine curve') subplot(3,2,3) plot(j,e)

title('exponential curve')

Page 4: matlab file

4

subplot(3,2,4) plot(l,r) title('ramp function') subplot(3,2,5) plot(m,u) title('unit step function') subplot(3,2,6)

stem(m,d) title('impulse function')

Page 5: matlab file

5

OUTPUT:

Page 6: matlab file

6

EXPERIMENT-2AIM- Write a MATLAB code to generate an amplitude modulated wave (AM).

THEORY- Amplitude Modulation (AM) is a method of impressing data on to an alternating current carrier waveform. The instantaneous amplitude varies depending on the instantaneous amplitude of the modulating signal. The general expression for AM wave is:-

v(t)= [ AC + vm(t) ] sin( wct )

CODE:

Am=input('enter the message signal amplitude');wm=input('enter the message signal frequency');Ac=input('enter the carrier wave amplitude');wc=input('enter the carrier wave frequency');

t=0:pi/60:2*pi;m=Am*sin(wm*t);c=Ac*sin(wc*t);v=(m + Ac).*sin(wc*t);subplot(3,1,1)plot(t,m)xlabel('time')ylabel('m(t)')title('Message Signal')subplot(3,1,2)

Page 7: matlab file

7

plot(t,c)xlabel('time')ylabel('c(t)')title('Carrier Signal')subplot(3,1,3)plot(t,v)xlabel('time')ylabel('v(t)')title('AM Signal')

Page 8: matlab file

8

OUTPUT:

Page 9: matlab file

9

EXPERIMENT-3AIM: Write a MATLAB code to generate a frequency modulated wave (FM).

THEORY:

Frequency Modulation (FM) is a method of changing the rest frequency of the carrier signal in accordance with the instantaneous amplitude of the modulating signal.

The general expression for FM wave is :-

V(t) = Asin Ф

Ф= ∫wc t + kf m(t)

Kf = Frequency Deviation constant

V(t) = A sin[ ∫[wc t + kf m(t)] ]

V(t)=Asin (wc t + mf sin(wmt))

CODE:

Am=input('enter the message signal amplitude');wm=input('enter the message signal frequency');Ac=input('enter the carrier wave amplitude');wc=input('enter the carrier wave frequency');mf=input('enter the modulation index'); t=0:pi/108:2*pi;m=Am*sin(wm*t);c=Ac*sin(wc*t);v=Ac*sin(wc*t + mf*sin(wm*t));subplot(2,2,1)plot(t,m)

Page 10: matlab file

10

xlabel('time')ylabel('m(t)')title('Message Signal')subplot(2,2,2)plot(t,c)xlabel('time')ylabel('c(t)')title('Carrier Signal')subplot(2,2,3.5)plot(t,v)xlabel('time')ylabel('v(t)')title('Frequency Modulated Signal')

Page 11: matlab file

11

OUTPUT:

Page 12: matlab file

12

EXPERIMENT-4

Page 13: matlab file

13

AIM: Write a MATLAB program to generate a DSB-SC (Double side band suppressed carrier) modulated wave.

THEORY: A signal is said to be DSB-SC or Product Modulated when it is generated by the multiplication of message signal and carrier wave part. The carrier wave is suppressed in the resultant modulated wave and the upper and lower side bands are present. The general expression is:

y = m(t) x sin (wct)

CODE:

Am=input('enter the message signal amplitude');wm=input('enter the message signal frequency');Ac=input('enter the carrier wave amplitude');wc=input('enter the carrier wave frequency');

t=0:pi/60:4*pi;m=Am*sin(wm*t);c=Ac*sin(wc*t);v=m.*sin(wc*t);subplot(2,2,1)plot(t,m)xlabel('time')ylabel('m(t)')title('Message Signal')subplot(2,2,2)plot(t,c)xlabel('time')ylabel('c(t)')title('Carrier Signal')subplot(2,2,3.5)plot(t,v)xlabel('time')ylabel('v(t)')title('DSB-SC Signal')

Page 14: matlab file

14

OUTPUT:

Page 15: matlab file

15

EXPERIMENT-5

Page 16: matlab file

16

AIM: Write a MATLAB code to generate an SSB-SC (Single Side Band-Suppressed Carrier) signal.

THEORY:

When we have equal frequency added on either side of an Amplitude Modulated signal, so we can use only one side band for our information and other side band can be utilized for some other information. The other side band can be removed using a suitable Band Pass Filter (BPF).

Hilbert transform is used to obtain ninety degree phase shift in the modulated wave and hence use it to generate SSB-SC. This process is known as Single Side Band-Suppressed Carrier method (SSB-SC).

m(t) x cos(wct) => Xdsb-sc ----> B.P.F. -----> Xssb-sc

SSB signal is given as follows:

vSSB(t)= m(t)cos(wct) ± mhsin(wct)

CODE:

Am=input('enter the message signal amplitude');wm=input('enter the message signal frequency');Ac=input('enter the carrier wave amplitude');wc=input('enter the carrier wave frequency');

t=0:pi/60:4*pi;m=Am*sin(wm*t);c=Ac*sin(wc*t);mh=hilbert(m);

vlsb=m.*cos(wc*t) + mh.*sin(wc*t);vusb=m.*cos(wc*t) - mh.*sin(wc*t); subplot(2,2,1)plot(t,m)

Page 17: matlab file

17

xlabel('time')ylabel('m(t)')title('Message Signal')subplot(2,2,2)plot(t,c)xlabel('time')ylabel('c(t)')title('Carrier Signal')subplot(2,2,3)plot(t,vlsb)xlabel('time')ylabel('vlsb')title('SSB-SC Signal(LSB)')subplot(2,2,4)plot(t,vusb)xlabel('time')ylabel('usb')title('SSB-SC Signal(USB)')

OUTPUT:

Page 18: matlab file

18

EXPERIMENT-6

Page 19: matlab file

19

AIM: Write a MATLAB code to generate a phase modulated wave (PM).

THEORY:

Phase Modulation (PM) is a method of changing the rest frequency of the carrier signal in accordance with the instantaneous amplitude of the modulating signal with some additional phase change.

The general expression for PM wave is:-

V(t) = Asin Ф

Ф= wct + kp m(t)

Kp = Phase Deviation constant

V(t) = A sin (wc t + kp m(t) )

CODE:

Am=input('enter the message signal amplitude');wm=input('enter the message signal frequency');Ac=input('enter the carrier wave amplitude');wc=input('enter the carrier wave frequency');kp=input('enter the modulation index');

t=0:pi/108:2*pi;

m=Am*sin(wm*t);c=Ac*sin(wc*t);v=Ac*sin(wc*t + kp*m);subplot(2,2,1)

Page 20: matlab file

20

plot(t,m)xlabel('time')ylabel('m(t)')title('Message Signal')subplot(2,2,2)plot(t,c)xlabel('time')ylabel('c(t)')title('Carrier Signal')subplot(2,2,3.5)plot(t,v)xlabel('time')ylabel('v(t)')title('Phase Modulated Signal')

OUTPUT:

Page 21: matlab file

21

EXPERIMENT-7

Page 22: matlab file

22

AIM: Write a MATLAB code to generate envelope detector

THEORY:

An envelope detector is an electronic circuit that takes a high-frequency signal as input and provides an output which is the envelope of the original signal. The capacitor in the circuit stores up charge on the rising edge, and releases it slowly through the resistor when the signal falls. The diode in series rectifies the incoming signal, allowing current flow only when the positive input terminal is at a higher potential than the negative input terminal.

If x(t)=[ac+m(t)]*coswt is amplitude modulated wave

Then ac+m(t) = envelope of x(t)

CODE:

Am=input('enter the message signal amplitude');wm=input('enter the message signal frequency');Ac=input('enter the carrier wave amplitude');wc=input('enter the carrier wave frequency');m=Am/Ac

t=0:0.001:1;m=Am*sin(2*pi*fm*t);c=Ac*cos(2*pi*fc*t);V=Ac*(m*sin(2*pi*fm*t)+1).*cos(2*pi*fc*t); subplot(2,2,1);plot(t,m);title('m(t)');xlabel('time');ylabel('amplitude'); subplot(2,2,2);

Page 23: matlab file

23

plot(t,c);title('c(t)');xlabel('time');ylabel('amplitude'); subplot(2,2,3);plot(t,V);title('AM signal');xlabel('time');ylabel('amplitude'); x(1)=0; for l=2:length(V); if V(l)>x(l-1); x(l)=V(l); else x(l)=x(l-1)*0.937; end;end; subplot(2,2,4);plot(t,x);title('envelope detector output');xlabel('time');ylabel('amplitude');

OUTPUT:

Page 24: matlab file

24

Page 25: matlab file

25

EXPERIMENT-8

AIM: Write a MATLAB code for Amplitude Shift Keying (A.S.K.) encoding technique

THEORY:Amplitude-shift keying (ASK) is a form of amplitude modulation that represents digital data as variations in the amplitude of a carrier wave. In an ASK system, the binary symbol 1 is represented by transmitting a fixed-amplitude carrier wave and fixed frequency for a bit duration of T seconds. If the signal value is 1 then the carrier signal will be transmitted; otherwise, a signal value of 0 will be transmitted.

CODE:

t=0:0.01:9.99;c=20*sin(2*pi*t);x=zeros(1,t); l=length(c);m=[1 1 0 1 1 0 0 0 1 1];for i=1:l; x(i)=m(ceil(i/100));end ASK=c.*x; subplot(2,2,1);plot(t,c);title('carrier signal'); subplot(2,2,2);plot(t,x);title('modulating signal');

Page 26: matlab file

26

subplot(2,2,[3,4]);plot(t,ASK);title('ASK');

Page 27: matlab file

27

OUTPUT:

Page 28: matlab file

28

EXPERIMENT-9

AIM: Write a MATLAB code for frequency shift keying (F.S.K.) encoding technique

THEORY:Frequency-shift keying (FSK) is a frequency modulation scheme in which digital information is transmitted through discrete frequency changes of a carrier wave. The simplest FSK is binary FSK (BFSK). BFSK uses a pair of discrete frequencies to transmit binary (0s and 1s) information

CODE:

t=0:0.1:100;w=1;w1=1.5;w2=.5; c=50*sin(w*t);subplot(2,3,1);plot(t,c);title('carrier wave'); c1=sin(w1*t);subplot(2,3,2);plot(t,c1);title('frequency 1'); c2=sin(w2*t);subplot(2,3,3);plot(t,c2);title('frequency 2'); m=square(2*pi*.03*t);

Page 29: matlab file

29

subplot(2,3,4);plot(t,m);title('modulating signal'); s=zeros(1001);for x=1:1000 if m(x)>0 s(x)=c1(x); else s(x)=c2(x); end;end; subplot(2,3,[5,6]);plot(t,s);title('FSK');

Page 30: matlab file

30

OUTPUT: