45
Exp No: Date: AMPLITUDE MODULATION AND DEMODULATION AIM: To implement Amplitude modulation and demodulation by using MATLAB. THEORY: Amplitude Modulation may be defined as a system in which the maximum amplitude of the carrier wave is made proportional to the instantaneous value (amplitude) of the modulating or baseband signal. Consider a sinusoidal carrier wave c(t) given as c(t)=Acos(w c t). Here, A is the maximum amplitude of the carrier wave and W c is the carrier frequency. Let x(t) denotes the modulating or base band signal then according to the amplitude modulation, the maximum amplitude A of the carrier will have to be made proportional to the instantaneous amplitude of the modulating signal x(t). The standard equation for amplitude modulation wave may be expressed as S ( t ) =x ( t ) cos ( w m t ) + A cos ( w c t ) In the process of amplitude modulation, the frequency and phase of the carrier remain constant where as the maximum amplitude varies according to the instantaneous value of the information signal. Sri Mittapalli College of Engineering, Guntur Page 1

Matlab Programss New

  • Upload
    rppvch

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Matlab Programss New

Exp No: Date:

AMPLITUDE MODULATION AND DEMODULATIONAIM: To implement Amplitude modulation and demodulation by using MATLAB.

THEORY:

Amplitude Modulation may be defined as a system in which the maximum amplitude of the carrier wave is made proportional to the instantaneous value (amplitude) of the modulating or baseband signal.

Consider a sinusoidal carrier wave c(t) given as c(t)=Acos(wct).

Here, A is the maximum amplitude of the carrier wave and Wc is the carrier frequency.

Let x(t) denotes the modulating or base band signal then according to the amplitude modulation, the maximum amplitude A of the carrier will have to be made proportional to the instantaneous amplitude of the modulating signal x(t).

The standard equation for amplitude modulation wave may be expressed as

S (t )=x (t ) cos (wm t )+A cos (w ct )In the process of amplitude modulation, the frequency and phase of the

carrier remain constant where as the maximum amplitude varies according to the instantaneous value of the information signal.

Sri Mittapalli College of Engineering, Guntur Page 1

Page 2: Matlab Programss New

Exp No: Date:

PROGRAM:

clc

clear all

close all

t=0:.001:.5;

am=1;

ac=1.5;

fm=10;

fc=100;

wc1=2*pi*fm;

wc2=2*pi*fc;

k=am/ac;

ct=ac*sin(wc2*t);

mt=am*sin(wc1*t);

s=(1+k*mt).*ct;

subplot(4,1,1)

plot(t,mt)

title('Modulating Signal')

subplot(4,1,2)

plot(t,ct)

title('carrier Signal')

subplot(4,1,3)

plot(t,s,t,ac+mt,t,-ac-mt)

title('Modulated Signal with enevelope')

subplot(4,1,4)

s2=(1/pi)*(ac+mt);

Sri Mittapalli College of Engineering, Guntur Page 2

Page 3: Matlab Programss New

Exp No: Date:

plot(t,mt,t,s2)

title('Demodulated Signal')

RESULT:

CONCLUSION: Amplitude modulation and demodulation is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 3

Page 4: Matlab Programss New

Exp No: Date:

FREQUENCY MODULATION AND DEMODULATION

AIM: To implement Frequency modulation and demodulation by using MATLAB.

THEORY:

Suppose the baseband data signal (the message) to be transmitted is xm(t) and the sinusoidal carrier is  , where fc is the carrier's base frequency and Ac is the carrier's amplitude. The modulator combines the carrier with the baseband data signal to get the transmitted signal:

In this equation,   is the instantaneous frequency of the oscillator and   is the frequency deviation, which represents the maximum shift away from fc in one direction, assuming xm(t) is limited to the range ±1.

Although it may seem that this limits the frequencies in use to fc ± fΔ, this neglects the distinction between instantaneous frequency and spectral frequency. The frequency spectrum of an actual FM signal has components extending out to infinite frequency, although they become negligibly small beyond a point.

Sri Mittapalli College of Engineering, Guntur Page 4

Page 5: Matlab Programss New

Exp No: Date:

PROGRAM:

clcclear allclose allt=0:.001:2; am=.1; ac=.2; fm=2; fc=10; k=2; wc1=2*pi*fm; wc2=2*pi*fc; mt=am*cos(wc1*t); ct=ac*cos(wc2*t); s=ac*cos(wc2*t+k*sin(wc1*t)); subplot(4,1,1) plot(t,mt) title('Modulating Signal') subplot(4,1,2) plot(t,ct) title('carrier Signal') subplot(4,1,3) plot(t,s,t,mt) title('Modulated Signal w.r.t message signal') subplot(4,1,4) s2=ac*(wc2+k*mt); plot(t,s2) title('Demodulated Signal')

Sri Mittapalli College of Engineering, Guntur Page 5

Page 6: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: Frequency modulation and demodulation is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 6

Page 7: Matlab Programss New

Exp No: Date:

QPSK MODULATION AND DEMODULATION

AIM: To implement QPSK modulation and demodulation by using MATLAB.

THEORY:

Modulation:

Quaternary PSK is also called as Quadrature PSK is another form of angle-modulated, constant amplitude digital modulation. QPSK is an M-ary encoding Scheme, where N=2 and M=4 (hence, the name “Quaternary”). With QPSK 4 output phases are possible for a single carrier frequency. Because there are about 4 output phases, there must be 4 different input conditions: 00, 01, 10, 11 are possible. Therefore with QPSk, the binary input data are combined into groups of two bits called dibits. Each dibit code generates one of the four possible output phases (+450, +1350, -450, -1350). Therefore for each two-bit dibit clocked into the modulator, a single output change occurs.

In transmitter the two dibits are clocked into bit splitter. One bit directed to I channel and other to Q- channel. I bit modulates a carrier that is in phase with reference oscillator and Q bit modulates a carrier that is 900 out of phase or Quadrature to the reference carrier. These are combined by a linear summer to get the QPSK output.

Demodulation:

The reverse process is done at the receiver where carrier recovery and product detectors are used to get the demodulated QPSk.

Sri Mittapalli College of Engineering, Guntur Page 7

Page 8: Matlab Programss New

Exp No: Date:

PROGRAM:

clcclose allclear allM = 4;x = randint(1,10,M);subplot(2,1,1),stairs(x)title('input signal')y=modulate(modem.pskmod(M),x);z = demodulate(modem.pskdemod(M),y);subplot(2,1,2),stairs(z)title('output demodulated signal')scatterplot(y)

Sri Mittapalli College of Engineering, Guntur Page 8

Page 9: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: QPSK modulation and demodulation is implemented by using MATLAB.

TIME DIVISION MULTIPLE ACCESS TECHNIQUE

AIM: To implement TDMA technique by using MATLAB.Sri Mittapalli College of Engineering, Guntur Page 9

Page 10: Matlab Programss New

Exp No: Date:

THEORY:

Time division multiple access (TDMA) is a channel access method for shared medium networks. It allows several users to share the same frequency channel by dividing the signal into different time slots. The users transmit in rapid succession, one after the other, each using his own time slot. This allows multiple stations to share the same transmission medium (e.g. radio frequency channel) while using only a part of its channel capacity. TDMA is used in the digital 2G cellular systems such as Global System for Mobile Communications (GSM), IS-136, Personal Digital Cellular (PDC) and IDEN, and in the Digital Enhanced Cordless Telecommunications (DECT) standard for portable phones. It is also used extensively in satellite systems, and combat-net radio systems. TDMA is a type of Time-division multiplexing, with the special point that instead of having one transmitter connected to one receiver, there are multiple transmitters. In the case of the uplink from a mobile phone to a base station this becomes particularly difficult because the mobile phone can move around and vary the timing advance required to make its transmission match the gap in transmission from its peers.

PROGRAM:

close all

Sri Mittapalli College of Engineering, Guntur Page 10

Page 11: Matlab Programss New

Exp No: Date:

clcclear alln=1:10;t1=randn(1,10);t2=randn(1,10);t3=randn(1,10);c=zeros(1,30);s=1;j=1;for i=1:3:30 c(i)=t1(j); c(i+1)=t2(j); c(i+2)=t3(j); j=j+1;endsubplot(7,1,1),stem(t1)title('Transmited signal in channel 1')subplot(7,1,2),stem(t2)title('Transmited signal in channel 2')subplot(7,1,3),stem(t3)title('Transmited signal in channel 3')subplot(7,1,4),stem(c)title('Transmited signal through channel')for k=1:3:30 r1(s)=c(k); r2(s)=c(k+1); r3(s)=c(k+2); s=s+1;endsubplot(7,1,5),stem(r1)title('Recieved signal in channel 1')subplot(7,1,6),stem(r2)title('Recieved signal in channel 2')subplot(7,1,7),stem(r3)title('Recieved signal in channel 3')

RESULT:

Sri Mittapalli College of Engineering, Guntur Page 11

Page 12: Matlab Programss New

Exp No: Date:

CONCLUSION: TDMA technique is implemented by using MATLAB.

CODE DIVISION MULTIPLE ACCESS TECHNIQUE

AIM: To implement CDMA technique by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 12

Page 13: Matlab Programss New

Exp No: Date:

THEORY:

CDMA is a spread spectrum multiple access[1] technique. A spread spectrum technique spreads the bandwidth of the data uniformly for the same transmitted power. Spreading code is a pseudorandom code that has a narrow Ambiguity function, unlike other narrow pulse codes. In CDMA a locally generated code runs at a much higher rate than the data to be transmitted. Data for transmission is combined via bitwise XOR (exclusive OR) with the faster code. The data signal with pulse duration of Tb is XOR’ed with the code signal with pulse duration of Tc. (Note: bandwidth is proportional to 1 / T where T = bit time) Therefore, the bandwidth of the data signal is 1 / Tb and the bandwidth of the spread spectrum signal is 1 / Tc. Since Tc is much smaller than Tb, the bandwidth of the spread spectrum signal is much larger than the bandwidth of the original signal. The ratio Tb / Tc is called spreading factor or processing gain and determines to a certain extent the upper limit of the total number of users supported simultaneously by a base station. Each user in a CDMA system uses a different code to modulate their signal. Choosing the codes used to modulate the signal is very important in the performance of CDMA systems. The best performance will occur when there is good separation between the signal of a desired user and the signals of other users. The separation of the signals is made by correlating the received signal with the locally generated code of the desired user. If the signal matches the desired user's code then the correlation function will be high and the system can extract that signal. If the desired user's code has nothing in common with the signal the correlation should be as close to zero as possible (thus eliminating the signal); this is referred to as cross correlation. If the code is correlated with the signal at any time offset other than zero, the correlation should be as close to zero as possible. This is referred to as auto-correlation and is used to reject multi-path interference.

PROGRAM:

clear all

Sri Mittapalli College of Engineering, Guntur Page 13

Page 14: Matlab Programss New

Exp No: Date:

close allclcuser1=[1 0 1 0];subplot(3,2,1),stem(user1)title('user1 data')user1code=[1 -1];user2=[1 1 1 0];subplot(3,2,2),stem(user2)title('user2 data')user2code=[-1 -1];c=kron(user1,user1code);d=kron(user2,user2code);y=c+d;subplot(3,2,3),stem(y)title('data send through channel')a=ones(1,length(y)/2); b=kron(a,user1code);rr=b.*y;o=reshape(rr,2,length(rr)/2);k=o(1,:)+o(2,:);user1_data=k>0;subplot(3,2,4),stem(user1_data)title('user1 decodded data') f=kron(a,user2code);ss=f.*y;m=reshape(ss,2,length(ss)/2);kk=m(1,:)+m(2,:);user2_data=kk>0;subplot(3,2,5),stem(user2_data)title('user2 decodded data')

Sri Mittapalli College of Engineering, Guntur Page 14

Page 15: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: CDMA technique is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 15

Page 16: Matlab Programss New

Exp No: Date:

EFFECT OF SAMPLING AND QUANTIZATION OF DIGITAL IMAGE

AIM: To study the effect of sampling and quantization of digital image by using MATLAB.

THEORY:

Formation of digital image from a continuous image basically involves two steps:

1. Sampling

2. Quantization

An image may be continuous with respect to x and y coordinates and also in amplitude. Digitizing the coordinate values is called sampling where as digitizing the amplitude values are called quantization.

Let the continuous image be f(x, y) which we want to convert into digital form. Let us take the continuous image along the line segment QR. The random variations that are seen are due to image noise. This function is sampled and quantized to get digital output.

Sampling is done by taking equally spaced samples along the line QR. the set of discrete locations gives the sampled function. However, the values of the samples still span a continuous range of gray-level values. In order to form a digital function, the gray level values also must be converted into discrete quantities. The continuous gray levels are quantized simply by assigning one of the discrete gray levels to each sample. The assignment is made depending on the vertical proximity of a sample to a vertical tick mark. Starting from the top of the image and carrying out this procedure line by line produces a two-dimensional digital image.

Sri Mittapalli College of Engineering, Guntur Page 16

Page 17: Matlab Programss New

Exp No: Date:

PROGRAM:

clcclear allclose alla=imread('cameraman.tif');imshow(a)title('Original image')% Down sampling of an imageb=imresize(a,2);figure, imshow(b)title('Sampled image')% Quantization of an Imagex1=grayslice(a,128);figure,imshow(x1,gray(128))title('Quantized image with 128 graylevels')x2=grayslice(a,64);figure,imshow(x2,gray(64))title('Quantized image with 64 graylevels')x3=grayslice(a,32);figure,imshow(x3,gray(32))title('Quantized image with 32 graylevels')x4=grayslice(a,8);figure,imshow(x4,gray(8))title('Quantized image with 8 graylevels')x5=grayslice(a,2);figure,imshow(x5,gray(2))title('Quantized image with 2 graylevels')

Sri Mittapalli College of Engineering, Guntur Page 17

Page 18: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: Effect of sampling and quantization of digital image is studied by using MATLAB.

FOURIER TRANSFORM

Sri Mittapalli College of Engineering, Guntur Page 18

Page 19: Matlab Programss New

Exp No: Date:

AIM: To implement Fourier transform on digital image by using MATLAB.

THEORY:

The discrete Fourier transform of two dimensional function f(x, y) of size M x N is given by

Where, u=0,1,2,3……..(M-1)

v=0,1,2,3……..(N-1)

Inverse discrete transform

F ( x , y )=∑u=0

M−1

∑v=0

N−1

f (u , v )∗ej 2 π( uxM + vy

N )

Where, x=0,1,2,3……..(M-1)

y=0,1,2,3……..(N-1)

The variables u and v represents transform or frequency variables and x and y represents spatial coordinates.

PROGRAM:

Sri Mittapalli College of Engineering, Guntur Page 19

F (u , v )=∑x=0

M−1

∑y=0

N−1

f ( x , y )∗e− j2 π (uxM + vy

N )

Page 20: Matlab Programss New

Exp No: Date:

clcclear allclose alla=zeros(30,30);a(5:24,13:17)=1;subplot(2,2,1),imshow(a)title('original image')b=fft2(a);subplot(2,2,2),imshow(b)title('Fourier transformed image')c=ifft2(b);subplot(2,2,3),imagesc(c)title('inverse fourier transformed image')

Sri Mittapalli College of Engineering, Guntur Page 20

Page 21: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: Fourier transform on digital image is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 21

Page 22: Matlab Programss New

Exp No: Date:

HADAMARD TRANSFORM

AIM: To implement Hadamard Transform on digital image by using MATLAB.

THEORY:

Hadamard transform depends upon the hadamard matrix. The matrix, which consists of square array of plus and minus one’s rows and columns is said to be hadamard matrix. The columns and rows in hadamard matrix are orthogonal .

The hadamard matrix of size N is given by

Hadamard matrix divided by 2 is called the sequence of the row. It is possible to construct a Hadamard matrix of order N=2n whose number of sign changes per row increases from 0 to N-1.

Where, v= Transformed Image

U= inverse Transform

Sri Mittapalli College of Engineering, Guntur Page 22

H2N=[H N HNH N −HN ]

v=HuHu=HvH

Page 23: Matlab Programss New

Exp No: Date:

PROGRAM:

clcclear allclose alla=8;n=2^a;m=hadamard(n)b=imread('cameraman.tif');subplot(2,2,1),imshow(b)title('original image')c = double(b) + 1;d=m*c*m;subplot(2,2,2),imshow(d)title('hadamard tranformed image')x=m*d*m;subplot(2,2,3),imagesc(x)title('inverse hadamard transformed image')

Sri Mittapalli College of Engineering, Guntur Page 23

Page 24: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: Hadamard Transform on digital image is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 24

Page 25: Matlab Programss New

Exp No: Date:

ENHANCEMENT TECHNIQUE IN SPATIAL FREQUENCY DOMAIN

AIM: To implement enhancement technique in spatial frequency domain by using MATLAB.

THEORY:

Gray level transformation is the transformation using which powerful processing approaches can be formulated. Because enhancement at any point depends only on the gray level at that point, techniques in this category are often referred to a point processing techniques.

The main objective of image enhancement is to improve the quality of an image event if no prior model of the degradation is available. This can be achieved by increasing the dominance of some features or by decreasing the ambiguity between different regions of the image.

Sri Mittapalli College of Engineering, Guntur Page 25

Page 26: Matlab Programss New

Exp No: Date:

PROGRAM:

clcclear allclose alla=imread('cameraman.tif');h = fspecial('motion',50,0);i = imfilter(a,h,'circular','conv');w2=deconvwnr(i,h);subplot(2,2,1),imshow(a)title('Original image')subplot(2,2,2),imshow(i)title('Blurred image')subplot(2,2,3),imshow(w2)title('Deblurred image')

Sri Mittapalli College of Engineering, Guntur Page 26

Page 27: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: Enhancement technique in spatial frequency domain is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 27

Page 28: Matlab Programss New

Exp No: Date:

POINT, LINE AND EDGE DETECTION TECHNIQUES USING DERIVATIVE OPERATIONS

AIM: To implement point, line and edge detection techniques using derivative operations by using MATLAB.

THEORY:

Consider an analog f(x) which represents a typical 1-D edge it is reasonable to consider the value x0 as edge point. One way to determine x0 is to find f’(x) or f”(x). The value of x0 can be found by looking at the max or min of f’(x) or by looking at the zero crossing of f”(x) where f”(x) changes its sign. The additional to determining x0 (the edge point). F’(x) can also be used in

estimating the strength and direction of the edge. If |f ' ( x )| is large => f(x) is changing very rapidly and a rapid change in intensity is indicated. If f’(x) is

positive => f(x) is increasing. If all values of x such that |f ' ( x )| is greater than a certain threshold are detected to be edges, an edge will appear as a line rather

than a point. To avoid this problem we further require |f ' ( x )| having a local maximum at the edge points. The informing about direction of edge is contained in f’(x) at x=xo (either positive or negative). The choice of threshold depends on its application. It is possible to choose the threshold adaptively.

The generalization of f(x) to 2-Dimensional function f(x,y) is the gradient ∇ f ( x , y ) given by

∇ f ( x , y )=∂ f ( x , y )∂ x

L̂x+∂ f ( x , y )

∂ yL̂y

Where, L̂x and L̂y are unit vectors in x and y directions respectively.

PROGRAM:

Sri Mittapalli College of Engineering, Guntur Page 28

Page 29: Matlab Programss New

Exp No: Date:

clear allclcclose alla=imread('flowers.tif');b=rgb2gray(a);% point detectionw1=[-1 -1 -1; -1 7 -1; -1 -1 -1];g=imfilter(double(b),w1);figure,imshow(g)title('point detected image')% Line detectionw2=[-1 2 -1; -1 2 -1; -1 2 -1];g3=imfilter(double(b),w2);figure,imshow(g3)title('line detected image')% edge detectione1 = edge(b,'sobel');e2 = edge(b,'canny');e3 = edge(b,'prewitt');e4 = edge(b,'roberts');figure,imshow(b)title('gray scale image')figure,imshow(e1)title('Sobel edge detector')figure,imshow(e2)title('canny edge detector')figure,imshow(e3)title('prewitt edge detector')figure,imshow(e4)title('roberts edge detector')

RESULT:

Sri Mittapalli College of Engineering, Guntur Page 29

Page 30: Matlab Programss New

Exp No: Date:

CONCLUSION: Point, line and edge detection techniques using derivative operations are implemented by using MATLAB.

COLOR CANCELLATION ENHANCEMENT TECHNIQUES

Sri Mittapalli College of Engineering, Guntur Page 30

Page 31: Matlab Programss New

Exp No: Date:

AIM: To implement color cancellation enhancement technique by using MATLAB.

THEORY:

The local enhancement is used to enhance the pixels in an area in the image, where the pixel size is almost negligible. Local enhancement has an advantage over histogram equalization and histogram specifications, i.e., it can enhance the information over small areas in an image.

The histogram equalization or histogram specification is performed on a center pixel, the center of the neighborhood region is moved to adjacent pixel location and the above process is repeated. While changing the center location the histogram obtained in the earlier location is updated. By using this process, it is possible to compute the histogram over every pixel.

PROGRAM:

Sri Mittapalli College of Engineering, Guntur Page 31

Page 32: Matlab Programss New

Exp No: Date:

clcclear allclose alla=imread('office_1.jpg');%Conversion of RGB to YIQ formatb=rgb2ntsc(a);figure,hist(b)%Histogram equalization of Y component aloneb(:,:,1)=histeq(b(:,:,1));figure,hist(b)%Conversion of YIQ to RGB formatc=ntsc2rgb(b);figure,imshow(a),title('original image')figure,imshow(c),title('Histogram equalized image')

RESULT:

Sri Mittapalli College of Engineering, Guntur Page 32

Page 33: Matlab Programss New

Exp No: Date:

CONCLUSION: Color cancellation enhancement technique is implemented by using MATLAB.

ECHO CANCELLATION IN SPEECH SIGNAL

Sri Mittapalli College of Engineering, Guntur Page 33

Page 34: Matlab Programss New

Exp No: Date:

AIM: To implement echo cancellation in speech signal by using MATLAB.

THEORY:

Echoes in speech cause a major problem in speaker recognition, speech enhancement ect. These echoes being caused at transmitter size increases its effect along with the noise. Echo cancellation is a priority for speech processing spectrum analysis is a non linear technique for detection of echoes. In this program read any speech file and calculate the number of samples and set a sample value from which instant an echo starts. Add a delayed signal to the original signal to obtain speech signal with echo. Now subtract the original signal from the echo signal In order to find the original signal without echo.

PROGRAM:

clcclear all

Sri Mittapalli College of Engineering, Guntur Page 34

Page 35: Matlab Programss New

Exp No: Date:

close all[x,fs,nbits]=wavread('SIREN.wav'); wavplay(x,fs);subplot(3,1,1),plot(x)title('original signal')xlen=length(x);a=5;R=ceil(fs);t=1:1:xlen; % y=zero(size(x));for i=1:1:R+1 y(i)=x(i);endfor i=R+1:1:xlen y(i)=x(i)+x(i-R);endwavplay(y,fs)subplot(3,1,2),plot(y)title('echo added signal')z=zeros(size(y));for i=1:1:R+1 z(i)=y(i);endfor i=R+1:1:xlen z(i)=y(i)-x(i-R);endwavplay(z,fs)subplot(3,1,3),plot(z)title('echo removed signal')

RESULT:

Sri Mittapalli College of Engineering, Guntur Page 35

Page 36: Matlab Programss New

Exp No: Date:

CONCLUSION: Echo cancellation in speech signal is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 36

Page 37: Matlab Programss New

Exp No: Date:

LMS ALGORITHM

AIM: To implement LMS algorithm by using MATLAB.

THEORY:

In much application requiring Neural Networks the necessary weights and bias may not be known. In such applications a learning algorithm which can design automatically the weights and bias is extremely useful. The simplest and most commonly used algorithm is LMS algorithm which is given by the following equations:

W ( k+1)=W (k )+2αe( k )PT (k )b (k+1)=b(k )+2αe(k )Where w=weights

b= Bias

α=Step size

e(k)=error

Sri Mittapalli College of Engineering, Guntur Page 37

Page 38: Matlab Programss New

Exp No: Date:

PROGRAM:

clcclear allp1=[1; -1; -1];%oranget1=-1;p2=[1 ;1 ;-1];%applet2=1;w=zeros(1,3);a=w*p1;while(a~=t1) w=w+2*0.2*(t1-a)*p1'; a=w*p1; enda=w*p2;while(a~=t2) w=w+2*0.2*(t2-a)*p2'; a=w*p2; endz=[1; -1; -1];z1=w*z;hold onplot(z1,'*'),plot(t1,'o')title('error plot for orange')hold offz2=[1 ;1 ;-1];z3=w*z2;figure, hold onplot(z3,'*'),plot(t2,'o')title('error plot for apple')

Sri Mittapalli College of Engineering, Guntur Page 38

Page 39: Matlab Programss New

Exp No: Date:

RESULT:

CONCLUSION: LMS algorithm is implemented by using MATLAB.

Sri Mittapalli College of Engineering, Guntur Page 39