matlab sp lab v sem ece

38
MATLAB Introduction MATLAB is a high performance language for technical computing .It integrates computation visualization and programming in an easy to use environment, Mat lab stands for matrix laboratory. It was written originally to provide easy access to matrix software developed by LINPACK (linear system package) and EISPACK (Eigen system package) projects. MATLAB is therefore built on a foundation of sophisticated matrix software in which the basic element is matrix that does not require pre dimensioning Typical uses of MATLAB 1. Math and computation 2. Algorithm development 3. Data acquisition 4. Data analysis ,exploration and visualization 5. Scientific and engineering graphics The main features of MATLAB 1. Advance algorithm for high performance numerical computation ,especially in the Field matrix algebra 2. A large collection of predefined mathematical functions and the ability to define one’s own functions. 3. Two-and three dimensional graphics for plotting and displaying data 4. A complete online help system 5. Powerful, matrix or vector oriented high level programming language for individual applications. 6. Toolboxes available for solving advanced problems in several application areas The MATLAB System The MATLAB system consists of five main parts:

Upload: mangwana250455758

Post on 28-Oct-2014

103 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Matlab Sp Lab v Sem Ece

MATLAB Introduction

MATLAB is a high performance language for technical computing .It integrates computation

visualization and programming in an easy to use environment, Mat lab stands for matrix

laboratory. It was written originally to provide easy access to matrix software developed by

LINPACK (linear system package) and EISPACK (Eigen system package) projects.

MATLAB is therefore built on a foundation of sophisticated matrix software in which the basic

element is matrix that does not require pre dimensioning

Typical uses of MATLAB

1. Math and computation

2. Algorithm development

3. Data acquisition

4. Data analysis ,exploration and visualization

5. Scientific and engineering graphics

The main features of MATLAB

1. Advance algorithm for high performance numerical computation ,especially in the

Field matrix algebra

2. A large collection of predefined mathematical functions and the ability to define one’s own

functions.

3. Two-and three dimensional graphics for plotting and displaying data

4. A complete online help system

5. Powerful, matrix or vector oriented high level programming language for individual

applications.

6. Toolboxes available for solving advanced problems in several application areas

The MATLAB System

The MATLAB system consists of five main parts:

Page 2: Matlab Sp Lab v Sem Ece

Development Environment.

This is the set of tools and facilities that help you use MATLAB functions and files. Many of

these tools are graphical user interfaces. It includes the MATLAB desktop and Command

Window, a command history, an editor and debugger, and browsers for viewing help, the

workspace, files, and the search path.

The MATLAB Mathematical Function Library.

This is a vast collection of computational algorithms ranging from elementary functions, like

sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse,

matrix Eigen values, Bessel functions, and fast Fourier transforms.

The MATLAB Language.

This is a high-level matrix/array language with control flow statements, functions, data

structures, input/output, and object-oriented programming features. It allows both "programming

in the small" to rapidly create quick and dirty throw-away programs, and "programming in the

large" to create large and complex application programs.

Graphics.

MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as

annotating and printing these graphs. It includes high-level functions for two-dimensional and

three-dimensional data visualization, image processing, animation, and presentation graphics. It

also includes low-level functions that allow you to fully customize the appearance of graphics as

well as to build complete graphical user interfaces on your MATLAB applications.

The MATLAB Application Program Interface (API).

This is a library that allows you to write C and FORTRAN programs that interact with

MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking), calling

MATLAB as a computational engine, and for reading and writing MAT-files.

Page 3: Matlab Sp Lab v Sem Ece

Features and capabilities of MATLAB

MATLAB

MATLAB Programming language

User written / built in functions

Graphics 2-D graphics 3-D graphics Color and lighting Animation

Computation Linear algebra Signal processing Quadrature Etc

External interface Interface with C and FORTRAN Programs

Tool boxes 1. Signal processing 2. Image processing 3. Control systems 4. Neural Networks 5. Communications 6. Robust control 7. Statistics 8. Embedded Targets

Page 4: Matlab Sp Lab v Sem Ece

Starting MATLAB

On Windows platforms, start MATLAB by double-clicking the MATLAB shortcut icon on

your Windows desktop. On UNIX platforms, start MATLAB by typing mat lab at the operating

system prompt. You can customize MATLAB startup. For example, you can change the

directory in which MATLAB starts or automatically execute MATLAB statements in a script

file named startup.m

MATLAB Desktop

When you start MATLAB, the MATLAB desktop appears, containing tools (graphical user

interfaces) for managing files, variables, and applications associated with MATLAB. The

following illustration shows the default desktop. You can customize the arrangement of tools

and documents to suit your needs.

Page 5: Matlab Sp Lab v Sem Ece

M-Files You can create your own matrices using M-files, which are text files containing MATLAB code. Use the MATLAB Editor or another text editor to create a file containing the same statements you would type at the MATLAB command Line. Save the file under a name that ends in .m. File New M-File Write on your Program Save the M-File Evaluate the Compilation

Page 6: Matlab Sp Lab v Sem Ece

Experiment No.1

Object: Generation of continuous & discrete elementary signals(periodic & nonperiodic) using mathematical expression.

Apparatus: A system equipped with Mat lab 7.0

Theory:

Signal

A signal is a codified message, that is, the sequence of states in a communication channel that encodes a message.

Discrete-time and continuous-time signals:

If for a signal, the quantities are defined only on a discrete set of times, we call it a discrete-time signal. In other words, a discrete-time real (or complex) signal can be seen as a function from the set of integers to the set of real (or complex) numbers.

A continuous-time real (or complex) signal is any real-valued (or complex-valued) function which is defined for all time t in an interval, most commonly an infinite interval.

Analog and digital signals

Less formally than the theoretical distinctions mentioned above, two main types of signals encountered in practice are analog and digital. In short, the difference between them is that digital signals are discrete and quantized, as defined below, while analog signals possess neither property.

Periodic Function

A function f in domain X is called periodic, if there exists a number P, different from zero, such that f(x + P) = f(x) for all values of x in the domain X. In this case, Number P is called the period of the function f in the domain X.

In general, period P has no need to be real (it may be a complex number). For example the exponential has period 2πi.

Non-periodic function

An aperiodic function (non-periodic function) is one that has no such period P for which f(x + P) = −f(x) for some P.

Properties of periodic Signal

If a function f is periodic with period P, then for all x in the domain of f and all integers n,

f(x + nP) = f(x).

Page 7: Matlab Sp Lab v Sem Ece

Program 1

%AIET/ECE/001

% Generation of continuous periodic elementary signal

x=[0:0.1:30];

y=sin(x);

plot(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('Periodic Signal A Exponential Waveform');

Output:

Fig. No. AIET/ECE/001

Page 8: Matlab Sp Lab v Sem Ece

Program 2

% AIET/ECE/002

% Generation of Discrete periodic elementary signal

x=[0:0.1:30];

y=sin(x);

stem(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('Discrete Periodic Signal A sinusoidal Waveform');

Output:

Output – Fig. No. AIET/ECE/002

Page 9: Matlab Sp Lab v Sem Ece

Program 3

% AIET/ECE/003

% Generation of continuous aperiodic elementary signal

x=[0:0.1:30];

y=exp(x);

plot(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('Periodic Signal A Exponential Waveform');

Output:

Output – Fig. No. AIET/ECE/003

Page 10: Matlab Sp Lab v Sem Ece

Program 4

% AIET/ECE/004

% Generation of Discrete Aperiodic elementary signal

x=[0:1:20];

y=exp(x);

stem(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('Discrete APeriodic Signal Exponential Waveform');

Output:

Output – Fig. No. AIET/ECE/004

 

 

Page 11: Matlab Sp Lab v Sem Ece

Experiment No. 2

Object: Generation of Continuous and Discrete Unit Step Signal.

Apparatus: A system equipped with Mat lab 7.0

Theory:

Continuous Unit step Function

It has constant amplitude of unity for the zero or positive value of time t, whereas it has a zero where for a negative value of t.

The unit step signal mathematically represented as

Continuous Unit Step Signal:

u (t) = 0

Discrete Unit Step Function

A discrete time unit step function is denoted by u(n). The value is unity for all positive values of the discrete values of n. It means that it unity for n≥0 while for other values of it is Zero.

Discrete Unit Step Function

u (n) = 0

In the form of discrete sequence it can be written as

u(n)= , , , , , , , , … … … … … … … … … … …

Page 12: Matlab Sp Lab v Sem Ece

Program 1

%AIET/ECE/005

%Generation of Continuous Unit Step Signal.

n=input('Enter the Length of Sequence N=');

t=0:1:n-1;

step=ones(1,n);

plot(t,step);

xlabel('Sequence');

ylabel('Amplitude');

title('Continuous Unit Step Function');

Output:

Output – Fig. No. AIET/ECE/005

Page 13: Matlab Sp Lab v Sem Ece

Program 2

%AIET/ECE/006

%Generation of Discrete Unit Step Signal.

n=input('Enter the Length of Sequence N=');

t=0:1:n-1;

step=ones(1,n);

stem(t,step);

xlabel('Sequence');

ylabel('Amplitude');

title('Discrete Unit Step Function');

Output:

Output – Fig. No. AIET/ECE/006

 

Page 14: Matlab Sp Lab v Sem Ece

Experiment No.3

Object: Generation of exponential and Ramp signal in continuous and discrete domain.

Apparatus: A system equipped with Mat lab 7.0

Theory:

Exponential function:

The exponential function is a function in mathematics. The application of this function to a value x is written as exp(x). Equivalently, this can be written in the form ex, where e is a mathematical constant, the base of the natural logarithm, which equals approximately 2.718281828, and is also known as Euler's number.

The complex exponential is one of the most fundamental and important signals in signal and system analysis. Its importance comes from its functions as a basis for periodic signals as well as being able to characterize linear, time-invariant signals. Before proceeding, you should be familiar with the ideas and functions of complex numbers.

Types of exponential signal:

Continuous Signal: x(t) =

Discrete Signal: x(n)=

Growing exponential signal b>0, for Decaying exponential signal b<0

Ramp Function:

A continuous time unit ramp function is that type of function which starts at t=0 & increase linearly with time t. It is denoted by r (t)

Mathematically: For (continuous time unit ramp function)

r t 0 for t 0, t for t 0

A discrete time unit ramp function is that type of function which starts at n=0 & increases with the each value of n increases linearly with discrete poins.

Mathematically: For (discrete time unit ramp function)

r n 0 for n 0, n for n 0

Page 15: Matlab Sp Lab v Sem Ece

Program 1

% AIET/ECE/007

% Generation of continuous Exponential elementry signal

x=[0:0.1:30];

y=exp(x);

stem(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('An Exponential Waveform');

Output:

Output – Fig. No. AIET/ECE/007

Page 16: Matlab Sp Lab v Sem Ece

Program 2

% AIET/ECE/008

% Generation of Discrete Exponential elementry signal

x=[0:0.1:30];

y=exp(x);

stem(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('An Discrete Exponential Waveform');

Output:

Output – Fig. No. AIET/ECE/008

Page 17: Matlab Sp Lab v Sem Ece

Program 3

% AIET/ECE/009

% Generation of Continuous Ramp signal

x=[0:1:30];

y=x;

plot(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('Continuous Ramp signal Waveform');

Output:

Output – Fig. No. AIET/ECE/009

Page 18: Matlab Sp Lab v Sem Ece

Program 4

% AIET/ECE/010

% Generation of Discrete Ramp signal

x=[0:1:30];

y=x;

stem(x,y);

xlabel('t');

ylabel('Amplitude of Signal');

title('Discrete Ramp signal Waveform');

Output:

Output – Fig. No. AIET/ECE/010

 

Page 19: Matlab Sp Lab v Sem Ece

Experiment No.4

Object: Continuous and discrete time Convolution (using basic definition).

Apparatus: Mat lab 7.0

Theory:

The convolution theorem says, roughly, that convolving two sequences is the same as multiplying their Fourier transforms. In order to make this precise, it is necessary to pad the two vectors Thus,

If M = fft([x zeros(1,length(y)-1)])

And N = fft([y zeros(1,length(x)-1)])

Then conv(x,y) = ifft(M.*N)

With zeros and ignore round off error.

w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the same operation as multiplying the polynomials whose coefficients are the elements of u and v.

Let m = length (u) and n = length(v).

Then w is the vector of length m+n-1 whose kth element is

w n u k v n k ,∞

The sum is over all the values of j which lead to legal subscripts for

u(j) and v(k+1-j),

Specifically j = max(1,k+1-n): min(k,m).

When m = n, this gives

w(1) = u(1)*v(1)

w(2) = u(1)*v(2)+u(2)*v(1)

w(n) = u(1)*v(n)+u(2)*v(n-1)+ ... +u(n)*v(1)...

w(2*n-1) = u(n)*v(n)

Page 20: Matlab Sp Lab v Sem Ece

Program 1

% AIET/ECE/011

% Generation of Convolution of two sequences

x=[0:1:30];

a=sin(x);

b=cos(x);

c=conv(a,b);

plot(c);

xlabel('input');

ylabel('convoluted output');

title('Convolution of two sequences');

Output:

Output – Fig. No. AIET/ECE/011

Page 21: Matlab Sp Lab v Sem Ece

Program 2

% AIET/ECE/012

% Generation of Convolution of two discrete sequences

x=[0:1:30];

y=[0 3 6 7 8 8 9];

c=conv(a,b);

stem(c);

xlabel('input');

ylabel('convoluted output');

title('Convolution of two sequences');

Output:

Output – Fig. No. AIET/ECE/012

 

Page 22: Matlab Sp Lab v Sem Ece

Experiment No.5

Object: Adding and subtracting two given signals. (Continuous as well as Discrete signals)

Apparatus: A system equipped with Mat lab 7.0

Theory:

A signal is a codified message, that is, the sequence of states in a communication channel that encodes a message.

Discrete-time and continuous-time signals:

If for a signal, the quantities are defined only on a discrete set of times, we call it a discrete-time signal. In other words, a discrete-time real (or complex) signal can be seen as a function from the set of integers to the set of real (or complex) numbers.A continuous-time real (or complex) signal is any real-valued (or complex-valued) function which is defined for all time t in an interval, most commonly an infinite interval..

Addition of two signals

Two signals can be added if they have similar properties in time or frequency domain.

f1(x)

+ y(x)= f1(x)+ f2(x)

+

f2(x)

Subtraction of two signals

Two signals can be subtracted if they have similar properties in frequency domain.

f1(x)

+ y(x)= f1(x) - f2(x)

_

f2(x)

f1(x) f2(x) y(x)

f1(x) f2(x) y(x)

Page 23: Matlab Sp Lab v Sem Ece

Program 1

% AIET/ECE/013

% Addition of two signals

x=[0:1:30];

a=sin(x);

b=cos(x);

c=a+b;

plot(c);

xlabel('input');

ylabel('Addition Amplitude');

title('Addition of two sequences');

Output:

Output – Fig. No. AIET/ECE/013

Page 24: Matlab Sp Lab v Sem Ece

Program 2

% AIET/ECE/014

% Addition of two discrete sequences

x=[0 5 7 8 9 3];

y=[2 3 5 6 7 1];

c=x+y;

stem(c);

xlabel('input');

ylabel('Addition Amplitude');

title('Addition of two sequences');

Output

Output – Fig. No. AIET/ECE/014

Page 25: Matlab Sp Lab v Sem Ece

Program 3

% AIET/ECE/015

% Subtraction of two signals

x=[0:1:30];

a=sin(x);

b=cos(x);

c=a-b;

plot(c);

xlabel('input');

ylabel('Subtraction Amplitude');

title('Subtraction of two sequences');

Output

Output – Fig. No. AIET/ECE/015

Page 26: Matlab Sp Lab v Sem Ece

Program 4

% AIET/ECE/016

% Substraction of two sequences

x=[0 5 7 8 9 3];

y=[2 3 5 6 7 1];

c=x-y;

stem(c);

xlabel('input');

ylabel('Substraction Amplitude');

title('Substraction of two sequences');

Output

Output – Fig. No. AIET/ECE/016

Page 27: Matlab Sp Lab v Sem Ece

Experiment No.6

Object: To generate uniform random numbers between (0, 1).

Apparatus: A system equipped with Mat lab 7.0

Theory:  

Random variable: A function which can take any value from the sample space and its range is set of real number is called a random variable of the experiment.

The methods for generating random numbers from any distribution all start with uniform random numbers. Once you have a uniform random number generator, you can produce random numbers from other distributions either directly or by using inversion or rejection methods.

Direct methods flow from the definition of the distribution.

The inversion method works due to a fundamental theorem that relates the uniform distribution to other continuous distributions.

The functional form of some distributions makes it difficult or time consuming to generate random numbers using direct or inversion methods. Rejection methods can sometimes provide an elegant solution in these cases.

rand :- rand command is used to generate Random variable in Mat lab.

To generate random numbers from a distribution with pdf given.

To use rejection methods you must first find another density, g, and a constant, c, so that the inequality below holds

for all x.

You then generate the random numbers you want using the following steps:

Generate a random number x from distribution G with density g.

Form the ratio.

Generate a uniform random number u.

If the product of u and r is less than one, return to x.

Page 28: Matlab Sp Lab v Sem Ece

Program 1

% AIET/ECE/017

% Generation of Random Numbers in between 0 & 1

x=input('Enter the length of Random Numbers to Generate N=');

r=rand(1,x) %Number of rows=1, Number of columns =x

stem(r);

title('Random Numbers in between 0 & 1');

xlabel('numbers');

ylabel('Amplitude');

Output:

Output – Fig. No. AIET/ECE/017

Page 29: Matlab Sp Lab v Sem Ece

Experiment No.7

Object: To plot Probability Density Function of Poisson distribution. Apparatus: A system equipped with Mat lab 7.0 Theory: Poisson distribution

The Poisson distribution is appropriate for applications that involve counting the number of times a random event occurs in a given amount of time, distance, area, etc. Sample applications that involve Poisson distributions include the number of Geiger counter clicks per second, the number of people walking into a store in an hour, and the number of flaws per 1000 feet of video tape.

The Poisson distribution is a one parameter discrete distribution that takes nonnegative integer values. The parameter, λ, is both the mean and the variance of the distribution. Thus, as the size of the numbers in a particular sample of Poisson random numbers gets larger, so does the variability of the numbers.

The Poisson and exponential distributions are related. If the number of counts follows the Poisson distribution, then the interval between individual counts follows the exponential distribution.

Probability Density Function of Poisson distribution

! , , , ,……..

Binomial distribution The binomial distribution models the total number of successes in repeated trials from an infinite population under the following conditions: Only two outcomes are possible on each of n trials. The probability of success for each trial is constant. All trials are independent of each other.

, , , …..

Where !

! !

And q = 1 – p

Page 30: Matlab Sp Lab v Sem Ece

Program 1

%AIET/ECE/019

% Generation of Probability Density Function of Poisson distribution

x=0:25;

y = poisspdf(x,5);

plot(x,y,'*');

xlabel('x');

ylabel('Probability Density Function');

title('Probability Density Function of Poisson distribution');

Output

Fig. No. AIET/ECE/019

Page 31: Matlab Sp Lab v Sem Ece

Program 2

%AIET/ECE/020

% Generation of Probability Density Function of Binomial distribution

x=0:25;

y = binopdf(x,15,0.5);

plot(x,y,'*');

xlabel('x');

ylabel('Probability Density Function');

title('Probability Density Function of Binomial distribution');

Output

Output – Fig. No. AIET/ECE/020

Page 32: Matlab Sp Lab v Sem Ece

Experiment No.8

Object: To generate random sequences with arbitrary distributions, means and variances for following :

(a) Rayleigh distribution

(b) Normal distributions: N(0,1).

(c) Gaussion distributions: N (mx, óx2)

Apparatus: A system equipped with Mat lab 7.0

Theory:

Rayleigh distribution

The Rayleigh distribution is a special case of the Weibull distribution. If A and B are the parameters of the Weibull distribution, then the Rayleigh distribution with parameter b is equivalent to the Weibull distribution with parameters

A=1/2b2and B=2.

If the component velocities of a particle in the x and y directions are two independent normal random variables with zero means and equal variances, then the distance the particle travels per unit time is distributed Rayleigh.

The normal distribution, also called the Gaussian distribution

The normal distribution, also called the Gaussian distribution, is an important family of continuous probability distributions, applicable in many fields. Each member of the family may be defined by two parameters, location and scale: the mean ("average", µ) and variance (standard deviation squared, σ2) respectively. The standard normal distribution is the normal distribution with a mean of zero and a variance of one (the red curves in the plots to the right).

To indicate that a real-valued random variable X is normally distributed with mean µ and

variance σ² ≥ 0, we write

Mean

Given a random sample x1, x2,…..xN , from an n-dimensional random variable X(i.e., realizations of N independent random variables with the same distribution as X), the sample mean is

Page 33: Matlab Sp Lab v Sem Ece

Variance

In probability theory and statistics, the variance of a random variable, probability distribution, or sample is one measure of statistical dispersion, averaging the squared distance of its possible values from the expected value (mean). Whereas the mean is a way to describe the location of a distribution, the variance is a way to capture its scale or degree of being spread out. The unit of variance is the square of the unit of the original variable. The positive square root of the variance, called the standard deviation, has the same units as the original variable and can be easier to interpret for this reason.

random variable X has expected value (mean) µ = E(X), then the variance Var(X) of X is given by:

This definition encompasses random variables that are discrete, continuous, or neither. Of all the points about which squared deviations could have been calculated, the mean produces the minimum value for the averaged sum of squared deviations.

The variance of random variable X is typically designated as Var(X), , or simply σ2. If a distribution does not have an expected value, as is the case for the Cauchy distribution, it does not have a variance either. Many other distributions for which the expected value does exist do not have a finite variance because the relevant integral diverges. An example is a Pareto distribution whose Pareto index k satisfies 1 < k ≤ 2.

Continuous case

If the random variable X is continuous with probability density function p(x),

Where and where the integrals are definite integrals taken for x ranging over the range

of X.

Discrete case

If the random variable X is discrete with probability mass function x1 p1... xn pn, ∑

Note: The variance is equal to the mean of the squares minus the square of the mean.

Page 34: Matlab Sp Lab v Sem Ece

Program 1

% AIET/ECE/021

% To generate random sequences with means and variances for Normal & Gaussian Distribution

N=input('Enter the length of Random Numbers to Generate N=');

n=1:N;

disp('Output');

R = normrnd(n,1./n)% mean=MU, Standard Deviation=SIGMA

[m,v]=normstat(n'*n,n'*n)%m=mean, v=Variance

Output:

Output – Fig. No. AIET/ECE/021

Page 35: Matlab Sp Lab v Sem Ece

Program 2

% AIET/ECE/022

% To generate random sequences with means and variances for Rayleigh Distribution

N=input('Enter the length of Random Numbers to Generate N=');

B=1:N;

disp('Output');

R = raylrnd(B)% mean=MU, Standard Deviation=SIGMA

[m,v]=raylstat(B)%m=mean, v=Variance

Output:

Output – Fig. No. AIET/ECE/022

Page 36: Matlab Sp Lab v Sem Ece

Experiment No. 9

Object: To generate the probability density functions.

Apparatus: A system equipped with Mat lab 7.0

Theory:

Rayleigh distribution

In probability theory and statistics, the Rayleigh distribution is a continuous probability distribution. It can arise when a two-dimensional vector (e.g. wind velocity, which consists of a speed value and a direction) has elements that are normally distributed, are uncorrelated, and have equal variance. The vector’s magnitude (e.g. wind speed) will then have a Rayleigh distribution. The distribution can also arise in the case of random complex numbers whose real and imaginary components are i.e. Gaussian. In that case, the absolute value of the complex number is Rayleigh-distributed. The distribution was so named after Lord Rayleigh.

The Rayleigh probability density function is .

for 0,∞

Normal distribution (Gaussian distribution)

The importance of the normal distribution as a model of quantitative phenomena in the natural and behavioral sciences is due in part to the central limit theorem. Many measurements, ranging from psychological to physical phenomena (in particular, thermal noise) can be approximated, to varying degrees, by the normal distribution. The normal distribution is also important for its relationship to least-squares estimation, one of the simplest and oldest methods of statistical estimation.

The Normal Probability density function

The continuous probability density function of the normal distribution is the Gaussian function

,1

√21

where σ > 0 is the standard deviation, the real parameter µ is the expected value, and

,

/

√2, ,

Page 37: Matlab Sp Lab v Sem Ece

Program 1

AIET/ECE/023

% To generate random sequences with Probability Density Function for Normal (Gaussian) Distribution

mu = [0:0.1:2];

[y i] = max(normpdf(1.5,mu,1))

disp('Output');

MLE = mu(i)

Output:

Output – Fig. No. AIET/ECE/023

Page 38: Matlab Sp Lab v Sem Ece

Program 2

% AIET/ECE/024

% To generate random sequences with Probability Density Function for Rayleigh Distribution

X=1:0.2:3;

B=1;

disp('Output');

P=raylpdf(X,B)%Probability Density Function

plot(X,P);

title('Probability Density Function for Rayleigh Distribution');

xlabel('input X');

ylabel('Probability Density Function');

Output:

Output – Fig. No. AIET/ECE/024