Saturday, October 31, 2009

matlab short notes /1 nov. 2009

%matlab short notes 25 March 2009
Getting Started
Expressions
Like most other programming languages, MATLAB provides mathematical expressions, but unlike most programming languages, these expressions involve entire matrices. The building blocks of expressions are Variables
Numbers
Operators
Functions
See also Examples of Expressions.

Variables


MATLAB does not require any type declarations or dimension statements. When MATLAB encounters a new variable name, it automatically creates the variable and allocates the appropriate amount of storage. If the variable already exists, MATLAB changes its contents and, if necessary, allocates new storage. For example,
num_students = 25
creates a 1-by-1 matrix named num_students and stores the value 25 in its single element.
Variable names consist of a letter, followed by any number of letters, digits, or underscores. MATLAB uses only the first 31 characters of a variable name. MATLAB is case sensitive; it distinguishes between uppercase and lowercase letters. A and a are not the same variable. To view the matrix assigned to any variable, simply enter the variable name.
Wednesday, March 25, 2009
Numbers
MATLAB uses conventional decimal notation, with an optional decimal point and leading plus or minus sign, for numbers. Scientific notation uses the letter e to specify a power-of-ten scale factor. Imaginary numbers use either i or j as a suffix. Some examples of legal numbers are
3 -99 0.0001
9.6397238 1.60210e-20 6.02252e23
1i -3.14159j 3e5i
All numbers are stored internally using the long format specified by the IEEE floating-point standard. Floating-point numbers have a finite precision of roughly 16 significant decimal digits and a finite range of roughly 10-308 to 10+308.
Operators
Expressions use familiar arithmetic operators and precedence rules.

+ Addition-Subtraction
*Multiplication/Division
\Left division (described in "Matrices and Linear Algebra" in the MATLAB documentation)
^Power'Complex conjugate transpose
( )Specify evaluation order
ting Started

Functions
MATLAB provides a large number of standard elementary mathematical functions, including abs, sqrt, exp, and sin. Taking the square root or logarithm of a negative number is not an error; the appropriate complex result is produced automatically. MATLAB also provides many more advanced mathematical functions, including Bessel and gamma functions. Most of these functions accept complex arguments. For a list of the elementary mathematical functions, type
help elfun
For a list of more advanced mathematical and matrix functions, type
help specfun
help elmat


Some of the functions, like sqrt and sin, are built in. Built-in functions are part of the MATLAB core so they are very efficient, but the computational details are not readily accessible. Other functions, like gamma and sinh, are implemented in M-files. There are some differences between built-in functions and other functions. For example, for built-in functions, you cannot see the code. For other functions, you can see the code and even modify it if you want.
Several special functions provide values of useful constants.
pi3.14159265...iImaginary unit, jSame as iepsFloating-point relative precision, realmin Smallest floating-point number, realmaxLargest floating-point number, InfInfinityNaNNot-a-number

Infinity is generated by dividing a nonzero value by zero, or by evaluating well defined mathematical expressions that overflow, i.e., exceed realmax. Not-a-number is generated by trying to evaluate expressions like 0/0 or Inf-Inf that do not have well defined mathematical values.
The function names are not reserved. It is possible to overwrite any of them with a new variable, such as
eps = 1.e-6
and then use that value in subsequent calculations. The original function can be restored with
clear eps
Wednesday, March 25, 2009
Examples of Expressions
You have already seen several examples of MATLAB expressions. Here are a few more examples, and the resulting values:
rho = (1+sqrt(5))/2
rho =
1.6180
a = abs(3+4i)
a =
5

z = sqrt(besselk(4/3,rho-i))
z =
0.3730+ 0.3214i
huge = exp(log(realmax))
huge =
1.7977e+308
toobig = pi*huge
toobig =
Inf
Wednesday, March 25, 2009
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 matlab 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.
Thursday, March 26, 2009
5:59 AM
Noise
Noise is considered to be any measurement that is not part of the phenomena of interest. Noise can be generated within the electrical components of the input amplifier (internal noise), or it can be added to the signal as it travels down the input wires to the amplifier (external noise). Techniques that you can use to reduce the effects of noise are described below.
Configure the input channels in differential mode. Refer to Channel Configuration for more information about channel configuration. Use signal wires that are twisted together rather than separate. Keep the signal wires as short as possible. Keep the signal wires as far away as possible from environmental electrical activity.


Filtering

Filtering also reduces signal noise. For many data acquisition applications, a low-pass filter is beneficial. As the name suggests, a low-pass filter passes the lower frequency components but attenuates the higher frequency components. The cut-off frequency of the filter must be compatible with the frequencies present in the signal of interest and the sampling rate used for the A/D conversion.

A low-pass filter that's used to prevent higher frequencies from introducing distortion into the digitized signal is known as an antialiasing filter if the cut-off occurs at the Nyquist frequency. That is, the filter removes frequencies greater than one-half the sampling frequency. These filters generally have a sharper cut-off than the normal low-pass filter used to condition a signal. Antialiasing filters are specified according to the sampling rate of the system and there must be one filter per input signal.
Communications Toolbox
White Gaussian Noise
The wgn function generates random matrices using a white Gaussian noise distribution. You specify the power of the noise in either dBW (decibels relative to a watt), dBm, or linear units. You can generate either real or complex noise.
For example, the command below generates a column vector of length 50 containing real white Gaussian noise whose power is 2 dBW. The function assumes that the load impedance is 1 ohm.
y1 = wgn(50,1,2);
To generate complex white Gaussian noise whose power is 2 Watts, across a load of 60 ohms, use either of the commands below. Notice that the ordering of the string inputs does not matter.
y2 = wgn(50,1,2,60,'complex','linear');
y3 = wgn(50,1,2,60,'linear','complex');
To send a signal through an additive white Gaussian noise channel, use the awgn function. See AWGN Channel for more information.


Imnoise


Add noise to an image
Syntax
J = imnoise(I,type)
J = imnoise(I,type,parameters)
Description
J = imnoise(I,type) adds noise of a given type to the intensity image I. type is a string that can have one of these values.
Value Description
'gaussian' Gaussian white noise with constant mean and variance
'localvar' Zero-mean Gaussian white noise with an intensity-dependent variance
'poisson' Poisson noise
'salt & pepper' On and off pixels
'speckle' Multiplicative noise.
Depending on which type of noise you specify, imnoise accepts additional parameters. If you omit these arguments, imnoise uses default values for the parameters. All numerical parameters are normalized; they correspond to operations with images with intensities ranging from 0 to 1.
J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.

J = imnoise(I,'localvar',V) adds zero-mean, Gaussian white noise of local variance V to the image I. V is an array of the same size as I.

J = imnoise(I,'localvar',image_intensity,var) adds zero-mean, Gaussian noise to an image I, where the local variance of the noise, var, is a function of the image intensity values in I. The image_intensity and var arguments are vectors of the same size, and plot(image_intensity,var) plots the functional relationship between noise variance and image intensity. The image_intensity vector must contain normalized intensity values ranging from 0 to 1.

J = imnoise(I,'poisson') generates Poisson noise from the data instead of adding artificial noise to the data. In order to respect Poisson statistics, the intensities of unit8 and uint16 images must correspond to the number of photons (or any other quanta of information). Double-precision images are used when the number of photons per pixel can be much larger than 65535 (but less than 10^12); the intensity values vary between 0 and 1 and correspond to the number of photons divided by 10^12.

J = imnoise(I,'salt & pepper',d) adds salt and pepper noise to the image I, where d is the noise density. This affects approximately d*prod(size(I)) pixels. The default is 0.05 noise density.

J = imnoise(I,'speckle',v) adds multiplicative noise to the image I, using the equation J = I+n*I, where n is uniformly distributed random noise with mean 0 and variance v. The default for v is 0.04.

Note The mean and variance parameters for 'gaussian', 'localvar', and 'speckle' noise types are always specified as if the image were of class double in the range [0, 1]. If the input image is of class uint8 or uint16, the imnoise function converts the image to double, adds noise according to the specified type and parameters, and then converts the noisy image back to the same class as the input.

Class Support
I can be of class uint8, uint16, int16, single, or double. The output image J is of the same class as I. If I has more than two dimensions it is treated as a multidimensional intensity image and not as an RGB image.
Example
I = imread('eight.tif');
J = imnoise(I,'salt & pepper',0.02);
imshow(I)
figure, imshow(J)


%Example
I = imread('eight.tif');
J = imnoise(I,'salt & pepper',0.02);
imshow(I)
figure, imshow(J)
%is this creation
%Example
I = imread('eight.tif');
J = imnoise(I,'salt & pepper',0.02);
imshow(I)
figure, imshow(J)
%'gaussian' %Gaussian white noise with constant mean and variance
%'localvar' %Zero-mean Gaussian white noise with an intensity-dependent variance
%'poisson' %Poisson noise
%'salt & pepper %On and off pixels
%'speckle' %Multiplicative noise.
I = imread('eight.tif');
>> plot(I) %image is observed;
%is this creation on noise 27 march 09.
%I %1 original numerical data
%plot(I) %2 graph form of original data
%imshow(I) %3 picture form of original data
%figure, imshow(I) %4 ******

%J %1n noised numerical data
%plot(J) %2n graph form of noised data
%imshow(J) %3n picture form of noised data
%figure, imshow(J) %4n ******


%Example
I = imread('eight.tif'); %original image,coin
J = imnoise(I,'salt & pepper',0.02); %adding noise
w=imread(‘YellowHlaMyintWin0012’) %Hla myint win
??? w=imread(‘YellowHlaMyintWin0012’) %Hla myint win
|
Error: The input character is not valid in MATLAB statements or expressions.

%I %1 original numerical data
%plot(I) %2 graph form of original data
%imshow(I) %3 picture form of original data
%figure, imshow(I) %4 ******

%J %1n noised numerical data
%plot(J) %2n graph form of noised data
%imshow(J) %3n picture form of noised data
%figure, imshow(J) %4n ******

Friday, March 27, 2009
%colon operator creation 27 march 09.

A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1];
1:10;
%is a row vector containing the integers from 1 to 10:
%1 2 3 4 5 6 7 8 9 10
%To obtain nonunit spacing, specify an increment. For example,
100:-7:50
%is
%100 93 86 79 72 65 58 51
%and
%0:pi/4:pi
%is
%0 0.7854 1.5708 2.3562 3.1416
%Subscript expressions involving colons refer to portions of a matrix:
%A(1:k,j)
%is the first k elements of the jth column of A. So
%sum(A(1:4,4))
%computes the sum of the fourth column. But there is a better way. The colon by itself refers to all the elements in a row or column of a matrix and the keyword end refers to the last row or column. So
sum(A(:,end))
%computes the sum of the elements in the last column of A
To make this B into Dürer's A, swap the two middle columns:
A = B(:,[1 3 2 4]) %swapping colon 2 & 3 of B
3/27/2009 1:50 PM
N = fix(10*rand(1,10))

N =

9 2 6 4 8 7 4 0 8 4




Generating Matrices


MATLAB provides four functions that generate basic matrices.

Zeros All zeros
Ones All ones
Rand Uniformly distributed random elements
randn Normally distributed random elements.


Here are some examples:
Z = zeros(2,4)
Z =
0 0 0 0
0 0 0 0

F = 5*ones(3,3)
F =
5 5 5
5 5 5
5 5 5

N = fix(10*rand(1,10))
N =
9 2 6 4 8 7 4 0 8 4

R = randn(4,4)
R =
0.6353 0.0860 -0.3210 -1.2316
-0.6014 -2.0046 1.2366 1.0556
0.5512 -0.4931 -0.6313 -0.1132
-1.0998 0.4620 -2.3252 0.3792

3/27/2009 2:26 PM

Getting Started

The load Function (NOT successful)


The load function reads binary files containing matrices generated by earlier MATLAB sessions, or reads text files containing numeric data. The text file should be organized as a rectangular table of numbers, separated by blanks, with one row per line, and an equal number of elements in each row. For example, outside of MATLAB, create a text file containing these four lines:
16.0 3.0 2.0 13.0
5.0 10.0 11.0 8.0
9.0 6.0 7.0 12.0
4.0 15.0 14.0 1.0
Store the file under the name magik.dat. Then the statement
load magik.dat
reads the file and creates a variable, magik, containing our example matrix.
An easy way to read data into MATLAB in many text or binary formats is to use Import Wizard.
Load function not successful
3/27/2009 3:42 PM
Getting Started
More About Matrices and Arrays
This section shows you more about working with matrices and arrays, focusing on Linear Algebra Arrays Multivariate Data Scalar Expansion Logical Subscripting The find Function
Linear Algebra
Informally, the terms matrix and array are often used interchangeably. More precisely, a matrix is a two-dimensional numeric array that represents a linear transformation. The mathematical operations defined on matrices are the subject of linear algebra. Dürer's magic square
A = [16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1 ]
provides several examples that give a taste of MATLAB matrix operations. You have already seen the matrix transpose, A'. Adding a matrix to its transpose produces a symmetric matrix:
A + A'

ans =
32 8 11 17
8 20 17 23
11 17 14 26
17 23 26 2

The multiplication symbol, *, denotes the matrix multiplication involving inner products between rows and columns. Multiplying the transpose of a matrix by the original matrix also produces a symmetric matrix:
A'*A
ans =
378 212 206 360
212 370 368 206
206 368 370 212
360 206 212 378
The determinant of this particular matrix happens to be zero, indicating that the matrix is singular:
d = det(A)

d =
0
The reduced row echelon form of A is not the identity:
R = rref(A)
R =
1 0 0 1
0 1 0 -3
0 0 1 3
0 0 0 0
Since the matrix is singular, it does not have an inverse. If you try to compute the inverse with
X = inv(A)
you will get a warning message:
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 9.796086e-018.
Roundoff error has prevented the matrix inversion algorithm from detecting exact singularity. But the value of rcond, which stands for reciprocal condition estimate, is on the order of eps, the floating-point relative precision, so the computed inverse is unlikely to be of much use.
The eigenvalues of the magic square are interesting:
e = eig(A)

e =
34.0000
8.0000
0.0000
-8.0000

One of the eigenvalues is zero, which is another consequence of singularity. The largest eigenvalue is 34, the magic sum. That is because the vector of all ones is an eigenvector:
v = ones(4,1)

v =
1
1
1
1

A*v

ans =
34
34
34
34
When a magic square is scaled by its magic sum,
P = A/34
the result is a doubly stochastic matrix whose row and column sums are all 1:
P =
0.4706 0.0882 0.0588 0.3824
0.1471 0.2941 0.3235 0.2353
0.2647 0.1765 0.2059 0.3529
0.1176 0.4412 0.4118 0.0294



Such matrices represent the transition probabilities in a Markov process. Repeated powers of the matrix represent repeated steps of the process. For our example, the fifth power
P^5
is
0.2507 0.2495 0.2494 0.2504
0.2497 0.2501 0.2502 0.2500
0.2500 0.2498 0.2499 0.2503
0.2496 0.2506 0.2505 0.2493

This shows that as k approaches infinity, all the elements in the kth power,p^k , approach 1/4.
Finally, the coefficients in the characteristic polynomial
poly(A)
are
1 -34 -64 2176 0
This indicates that the characteristic polynomial
*******************************************
The constant term is zero, because the matrix is singular, and the coefficient of the cubic term is -34, because the matrix is magic!.
Arrays
When they are taken away from the world of linear algebra, matrices become two-dimensional numeric arrays. Arithmetic operations on arrays are done element by element. This means that addition and subtraction are the same for arrays and matrices, but that multiplicative operations are different. MATLAB uses a dot, or decimal point, as part of the notation for multiplicative array operations.
The list of operators includes
+ Addition
- Subtraction
.* Element-by-element multiplication
./ Element-by-element division.
\ Element-by-element left division
.^ Element-by-element power
.' Unconjugated array transpose
A = [16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1 ] % Dürer magic square
If the Dürer magic square is multiplied by itself with array multiplication
A.*A
the result is an array containing the squares of the integers from 1 to 16, in an unusual order:
ans =
256 9 4 169
25 100 121 64
81 36 49 144
16 225 196 1
Building Tables
Array operations are useful for building tables. Suppose n is the column vector
n = (0:9)';
Then
pows = [n n.^2 2.^n]
builds a table of squares and powers of 2:
pows =
0 0 1
1 1 2
2 4 4
3 9 8
4 16 16
5 25 32
6 36 64
7 49 128
8 64 256
9 81 512


he elementary math functions operate on arrays element by element. So
format short g
x = (1:0.1:2)';
logs = [x log10(x)]
builds a table of logarithms.
logs =
1.0 0
1.1 0.04139
1.2 0.07918
1.3 0.11394
1.4 0.14613
1.5 0.17609
1.6 0.20412
1.7 0.23045
1.8 0.25527
1.9 0.27875
2.0 0.30103
3/27/2009 9:29 PM
To contd. Getting started-matrices and arrays-more about matrices-arrays
6/12/2009 3:42 AM
Multivariate Data
MATLAB uses column-oriented analysis for multivariate statistical data. Each column in a data set represents a variable and each row an observation. The (i,j)th element is the ith observation of the jth variable.
As an example, consider a data set with three variables:
Heart rate
Weight
Hours of exercise per week
For five observations, the resulting array might look like
D = [ 72 134 3.2
81 201 3.5
69 156 7.1
82 148 2.4
75 170 1.2 ]
The first row contains the heart rate, weight, and exercise hours for patient 1, the second row contains the data for patient 2, and so on.

Now you can apply many MATLAB data analysis functions to this data set. For example, to obtain the mean and standard deviation of each column, use
mu = mean(D), sigma = std(D)

mu =
75.8 161.8 3.48
sigma =
5.6303 25.499 2.2107
For a list of the data analysis functions available in MATLAB, type
help datafun
If you have access to the Statistics Toolbox, type
help stats
6/12/2009 3:42 AM
Scalar Expansion
Matrices and scalars can be combined in several different ways. For example, a scalar is subtracted from a matrix by subtracting it from each element. The average value of the elements in our magic square is 8.5, so
B = A - 8.5
forms a matrix whose column sums are zero:
B =
7.5 -5.5 -6.5 4.5
-3.5 1.5 2.5 -0.5
0.5 -2.5 -1.5 3.5
-4.5 6.5 5.5 -7.5
sum(B) % column sums
ans =
0 0 0 0
With scalar expansion, MATLAB assigns a specified scalar to all indices in a range. For example,
B(1:2,2:3) = 0 % elements in 1st row. & 2nd row. AND 2nd column & 3rd column

zeroes out a portion of B:
B =
7.5 0 0 4.5
-3.5 0 0 -0.5
0.5 -2.5 -1.5 3.5
-4.5 6.5 5.5 -7.5
B(1:2,2:3)=16; % elements in 1st row. & 2nd row. AND 2nd column
& 3rd column
>> B
B =

7.5000 16.0000 16.0000 4.5000
-3.5000 16.0000 16.0000 -0.5000
0.5000 -2.5000 -1.5000 3.5000
-4.5000 6.5000 5.5000 -7.5000
Amen amen amen6/12/2009 3:42 AM


Controlling Command Window Input and Output
So far, you have been using the MATLAB command line, typing functions and expressions, and seeing the results printed in the Command Window. This section describes The format Function Suppressing Output Entering Long Statements Command Line Editing
The format Function
The format function controls the numeric format of the values displayed by MATLAB. The function affects only how numbers are displayed, not how MATLAB computes or saves them. Here are the different formats, together with the resulting output produced from a vector x with components of different magnitudes.
Note To ensure proper spacing, use a fixed-width font, such as Courier.
x = [4/3 1.2345e-6]
format short
1.3333 0.0000
format short e
1.3333e+000 1.2345e-006
format short g
1.3333 1.2345e-006
format long
1.33333333333333 0.00000123450000
format long e
1.333333333333333e+000 1.234500000000000e-006
format long g
1.33333333333333 1.2345e-006
format bank
1.33 0.00
format rat
4/3 1/810045
format hex
3ff5555555555555 3eb4b6231abfd271
If the largest element of a matrix is larger than 103 or smaller than 10-3, MATLAB applies a common scale factor for the short and long formats.
In addition to the format functions shown above
format compact
suppresses many of the blank lines that appear in the output. This lets you view more information on a screen or window. If you want more control over the output format, use the sprintf and fprintf functions.
Amen amen amen3/28/2009 8:35 AM
Next---suppressing output
Sunday, March 29, 2009
double-click
vb. To press and release a mouse button twice without moving the mouse. Double-clicking is a means of rapidly selecting and activating a program or program feature. Compare click, drag.
Suppressing Output
If you simply type a statement and press Return or Enter, MATLAB automatically displays the results on screen. However, if you end the line with a semicolon, MATLAB performs the computation but does not display any output. This is particularly useful when you generate large matrices. For example,
A = magic(100);
Entering Long Statements
If a statement does not fit on one line, use an ellipsis (three periods), ..., followed by Return or Enter to indicate that the statement continues on the next line. For example,
s = 1 -1/2 + 1/3 -1/4 + 1/5 - 1/6 + 1/7 ...
- 1/8 + 1/9 - 1/10 + 1/11 - 1/12;
Blank spaces around the =, +, and - signs are optional, but they improve readability.
Sunday, March 29, 2009
Examples -- Using MATLAB Plotting Tools
Suppose you want to graph the function y = x3 over the x domain -1 to 1. The first step is to generate the data to plot.
It is simple to evaluate a function because MATLAB can distribute arithmetic operations over all elements of a multivalued variable.
For example, the following statement creates a variable x that contains values ranging from -1 to 1 in increments of 0.1 (you could also use the linspace function to generate data for x). The second statement raises each value in x to the third power and stores these values in y:
x = -1:.1:1; % Define the range of x
y = x.^3; % Raise each element in x to the third power
Now that you have generated some data, you can plot it using the MATLAB plotting tools. To start the plotting tools, type
plottools
MATLAB displays a figure with plotting tools attached


Plotting Two Variables
A simple line graph is a suitable way to display x as the independent variable and y as the dependent variable. To do this, select both variables (click to select, then Shift-click to select again), then right-click to display the context menu.
Select plot(x,y) from the menu. MATLAB creates the line graph in the figure area. The black squares indicate that the line is selected and you can edit its properties with the Property Editor.
To contd.-Getting started-GRAPHICS
3/30/2009 3:12 AM
Case Study: Curve Fitting
This section provides an overview of some of the MATLAB basic data analysis capabilities in the form of a case study. The examples that follow work with a collection of census data, using MATLAB functions to experiment with fitting curves to the data: Polynomial fit
Analyzing residuals
Exponential fit Error bounds
This section also tells you how to use the Basic Fitting interface to perform curve fitting tasks.
Loading the Data
The file census.mat contains U.S. population data for the years 1790 through 1990. Load it into MATLAB:
load census
Your workspace now contains two new variables, cdate and pop: cdate is a column vector containing the years from 1790 to 1990 in increments of 10. pop is a column vector with the U.S. population figures that correspond to the years in cdate.
Polynomial Fit
A first try in fitting the census data might be a simple polynomial fit. Two MATLAB functions help with this process.
Curve Fitting Function Summary
Function Description
Polyfit Polynomial curve fit.
Polyval Evaluation of polynomial fit.

The MATLAB polyfit function generates a "best fit" polynomial (in the least squares sense) of a specified order for a given set of data. For a polynomial fit of the fourth-order
p = polyfit(cdate,pop,4)
Warning: Polynomial is badly conditioned. Remove repeated data
points or try centering and scaling as described in HELP POLYFIT.
p =
1.0e+05 *

0.0000 -0.0000 0.0000 -0.0126 6.0020

The warning arises because the polyfit function uses the cdate values as the basis for a matrix with very large values (it creates a Vandermonde matrix in its calculations - see the polyfit M-file for details). The spread of the cdate values results in scaling problems. One way to deal with this is to normalize the cdate data.
Preprocessing: Normalizing the Data
Normalization is a process of scaling the numbers in a data set to improve the accuracy of the subsequent numeric computations. A way to normalize cdate is to center it at zero mean and scale it to unit standard deviation:
sdate = (cdate - mean(cdate))./std(cdate)
Now try the fourth-degree polynomial model using the normalized data:
p = polyfit(sdate,pop,4)
p =
0.7047 0.9210 23.4706 73.8598 62.2285
Evaluate the fitted polynomial at the normalized year values, and plot the fit against the observed data points:
pop4 = polyval(p,sdate);
plot(cdate,pop4,'-',cdate,pop,'+'), grid on
amen amen amen3/30/2009 4:25 AM


Analyzing Residuals
A measure of the "goodness" of fit is the residual, the difference between the observed and predicted data. Compare the residuals for the various fits, using normalized cdate values. It's evident from studying the fit plots and residuals that it should be possible to do better than a simple polynomial fit with this data set.
%fit
p1 = polyfit(sdate,pop,1);
pop1 = polyval(p1,sdate);
plot(cdate,pop1,'b-',cdate,pop,'g+')
%residuals
res1 = pop - pop1;
figure, plot(cdate,res1,'g+')
%fit
p = polyfit(sdate,pop,4);
pop4 = polyval(p,sdate);
plot(cdate,pop4,'b-',cdate,pop,'g+');
%residual
res4 = pop - pop4;
figure, plot(cdate,res4,'g+');
amen amen amen 3/30/2009 4:48 AM
Sunday, April 05, 2009 2:46 PM
ommunications Toolbox
Convolution
This toolbox offers two equivalent ways to convolve a pair of Galois vectors:
Use the conv function, as described in Multiplication and Division of Polynomials. This works because convolving two vectors is equivalent to multiplying the two polynomials whose coefficients are the entries of the vectors.

Use the convmtx function to compute the convolution matrix of one of the vectors, and then multiply that matrix by the other vector. This works because convolving two vectors is equivalent to filtering one of the vectors by the other. The equivalence permits the representation of a digital filter as a convolution matrix, which you can then multiply by any Galois vector of appropriate length.
Tip If you need to convolve large Galois vectors, then multiplying by the convolution matrix might be faster than using conv.
Example
The example below computes the convolution matrix for a vector b in GF(4), representing the numerator coefficients for a digital filter. It then illustrates the two equivalent ways to convolve b with x over the Galois field.
m = 2; b = gf([1 2 3]',m);
n = 3; x = gf(randint(n,1,2^m),m);
C = convmtx(b,n); % Compute convolution matrix.
v1 = conv(b,x); % Use conv to convolve b with x
v2 = C*x; % Use C to convolve b with x.
%outputs
>> v1

v1 = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)

Array elements =

3
1
0
3
1

>> v2

v2 = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)

Array elements =

3
1
0
3
1
%very good v1=v2 QED
Amen amen amen Sunday, April 05, 2009
ATLAB Function Reference
Polynomials
Conv Convolution and polynomial multiplication
Deconv Deconvolution and polynomial division
Poly Polynomial with specified roots
Polyder Polynomial derivative
Polyeig Polynomial eigenvalue problem
Polyfit Polynomial curve fitting
Polyint Analytic polynomial integration
Polyval Polynomial evaluation
Polyvalm Matrix polynomial evaluation
Residue Convert between partial fraction expansion and polynomial coefficients
Roots Polynomial roots

Data Analysis and Fourier Transforms Interpolation and Computational Geometry

%polyder
%Polynomial derivative
%5 april 09

Syntax

k = polyder(p)
k = polyder(a,b)
[q,d] = polyder(b,a)
Description
%The polyder function calculates the derivative of polynomials,
%polynomial products, and polynomial quotients.
%The operands a, b, and p are vectors whose elements are the coefficients
%of a polynomial in descending powers.

k = polyder(p) returns the derivative of the polynomial p.

k = polyder(a,b) returns the derivative of the product of the polynomials a and b.

[q,d] = polyder(b,a) returns the numerator q and denominator d of the derivative
of the polynomial quotient b/a.
Examples
%The derivative of the product is obtained with
a = [3 6 9];
b = [1 2 0];
k = polyder(a,b)
k =
12 36 42 18

products
>> %The derivative of the product is obtained with
a = [3 6 9];
b = [1 2 0];
k = polyder(a,b)

k =

12 36 42 18

>>
Monday, April 06, 2009

mage Processing Toolbox User's Guide

Convolution


Linear filtering of an image is accomplished through an operation called convolution. Convolution is a neighborhood operation in which each output pixel is the weighted sum of neighboring input pixels. The matrix of weights is called the convolution kernel, also known as the filter. A convolution kernel is a correlation kernel that has been rotated 180 degrees.

For example, suppose the image is
A = [17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9]



and the convolution kernel is
h = [8 1 6
3 5 7
4 9 2]
Amen
%Mathematics

%Convolution and Deconvolution
%3 april 09
%Polynomial multiplication and division correspond to
%the operations convolution and deconvolution.
%The functions conv and deconv implement these operations.

%Consider the polynomials -- and--- . To compute their product,
a = [1 2 3]; b = [4 5 6];
c = conv(a,b)

%c =
% 4 13 28 27 18

%Use deconvolution to divide back out of the product.
%[q,r] = deconv(c,a)

%q =
% 4 5 6

%r =
% 0 0 0 0 0
% outputs

To get started, select MATLAB Help or Demos from the Help menu.

>> %Consider the polynomials -- and--- . To compute their product,
a = [1 2 3]; b = [4 5 6];
c = conv(a,b)

%c =
% 4 13 28 27 18

%Use deconvolution to divide back out of the product.
%[q,r] = deconv(c,a)

c =

4 13 28 27 18

>> [q,r] = deconv(c,a)

q =

4 5 6


r =

0 0 0 0 0
Monday, April 06, 2009 3:40 PM
Image Processing Toolbox User's Guide
Linear Filtering and Filter Design
The Image Processing Toolbox provides a number of functions for designing and implementing two-dimensional linear filters for image data. This chapter describes these functions and how to use them effectively. Linear FilteringProvides an explanation of linear filtering and how it is implemented in the toolbox. This topic describes filtering in terms of the spatial domain, and is accessible to anyone doing image processing.Filter DesignDiscusses designing two-dimensional finite impulse response (FIR) filters. This section assumes you are familiar with working in the frequency domain.


Image Processing Toolbox User's Guide
Linear Filtering
Filtering is a technique for modifying or enhancing an image. For example, you can filter an image to emphasize certain features or remove other features. Image processing operations implemented with filtering include smoothing, sharpening, and edge enhancement.

Filtering is a neighborhood operation, in which the value of any given pixel in the output image is determined by applying some algorithm to the values of the pixels in the neighborhood of the corresponding input pixel. A pixel's neighborhood is some set of pixels, defined by their locations relative to that pixel. (See Neighborhood and Block Operations, for a general discussion of neighborhood operations.)

Linear filtering is filtering in which the value of an output pixel is a linear combination of the values of the pixels in the input pixel's neighborhood.

This section discusses linear filtering in MATLAB and the Image Processing Toolbox. It includes
A description of filtering, using convolution and correlation
A description of how to perform filtering using the imfilter function
A discussion about using predefined filter types
See Filter Design for information about how to design filters.
Amen amen amen


Correlation

The operation called correlation is closely related to convolution. In correlation, the value of an output pixel is also computed as a weighted sum of neighboring pixels. The difference is that the matrix of weights, in this case called the correlation kernel, is not rotated during the computation. The filter design functions in the Image Processing Toolbox return correlation kernels.

The following figure shows how to compute the (2,4) output pixel of the correlation of A, assuming h is a correlation kernel instead of a convolution kernel, using these steps: Slide the center element of the correlation kernel so that lies on top of the (2,4) element of A. Multiply each weight in the correlation kernel by the pixel of A underneath. Sum the individual products from step 3.
Fig $$$$$$$$$$$$$$$$$$$$$$$$$$$$$
amen
Wednesday, April 08, 2009
Wednesday, April 15, 2009

Multiplication and Division of Polynomials


To multiply and divide polynomials, use conv and deconv on Galois vectors that represent the polynomials. Multiplication and division of polynomials is equivalent to convolution and deconvolution of vectors. The deconv function returns the quotient of the two polynomials as well as the remainder polynomial. Examples are below.
m = 4;
apoly = gf([4 5 3],m); % A^2 x^2 + (A^2 + 1) x + (A + 1)
bpoly = gf([1 1],m); % x + 1
xpoly = gf([1 0],m); % x
% Product is A^2 x^3 + x^2 + (A^2 + A) x + (A + 1).
cpoly = conv(apoly,bpoly);
[a2,remd] = deconv(cpoly,bpoly); % a2==apoly. remd is zero.
[otherpol,remd2] = deconv(cpoly,xpoly); % remd is nonzero.


The multiplication and division operators in Arithmetic in Galois Fields multiply elements or matrices, not polynomial.
%Multiplication and Division of Polynomials
%15 APRIL 2009
%eureka eureka

%To multiply and divide polynomials, use conv and deconv on Galois vectors that represent
%the polynomials.
%Multiplication and division of polynomials is equivalent to convolution and deconvolution
% of vectors.
% The deconv function returns the quotient of the two polynomials as well as
%the remainder polynomial. Examples are below.
m = 4;
apoly = gf([4 5 3],m); % A^2 x^2 + (A^2 + 1) x + (A + 1)
bpoly = gf([1 1],m); % x + 1
xpoly = gf([1 0],m); % x
% Product is A^2 x^3 + x^2 + (A^2 + A) x + (A + 1).
cpoly = conv(apoly,bpoly);
[a2,remd] = deconv(cpoly,bpoly); % a2==apoly. remd is zero.
[otherpol,remd2] = deconv(cpoly,xpoly); % remd is nonzero.

%outputs

m = 4;
apoly = gf([4 5 3],m); % A^2 x^2 + (A^2 + 1) x + (A + 1)
bpoly = gf([1 1],m); % x + 1
xpoly = gf([1 0],m); % x
% Product is A^2 x^3 + x^2 + (A^2 + A) x + (A + 1).
cpoly = conv(apoly,bpoly);
[a2,remd] = deconv(cpoly,bpoly); % a2==apoly. remd is zero.
[otherpol,remd2] = deconv(cpoly,xpoly); % remd is n
apoly

apoly = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 5 3
bpoly

bpoly = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

1 1
cpoly

cpoly = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 1 6 3
otherpol

otherpol = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 1 6

apoly = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 5 3
bpoly

bpoly = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

1 1
otherpol

otherpol = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 1 6
conv(otherpol,bpoly)

ans = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 5 7 6
cpoly

cpoly = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 1 6 3
conv(apoly,bpoly)

ans = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

4 1 6 3

Wednesday, April 15, 2009
%computes the convolution matrix for a vector b in GF(4),
%representing the numerator coefficients for a digital filter.
%15 april 2009
%Example
%The example below computes the convolution matrix for a vector b in GF(4),
%representing the numerator coefficients for a digital filter.
%It then illustrates the two equivalent ways to convolve b with x over the Galois field.

m = 2; b = gf([1 2 3]',m);
n = 3; x = gf(randint(n,1,2^m),m);
C = convmtx(b,n); % Compute convolution matrix.
v1 = conv(b,x); % Use conv to convolve b with x
v2 = C*x; % Use C to convolve b with x.

%outputs

To get started, select MATLAB Help or Demos from the Help menu.

>> m = 2; b = gf([1 2 3]',m);
n = 3; x = gf(randint(n,1,2^m),m);
C = convmtx(b,n); % Compute convolution matrix.
v1 = conv(b,x); % Use conv to convolve b with x
v2 = C*x; % Use C to convolve b with x.
>> b

b = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)

Array elements =

1
2
3

>> v1

v1 = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)

Array elements =

3
1
0
3
1

>> v2

v2 = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)

Array elements =

3
1
0
3
1

>> b

b = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)

Array elements =

1
2
3

>>
Wednesday, April 15, 2009

Discrete Fourier Transform


The discrete Fourier transform is an important tool in digital signal processing. This toolbox offers these tools to help you process discrete Fourier transforms:

%fft, which transforms a Galois vector

%ifft, which inverts the discrete Fourier transform on a Galois vector

%dftmtx, which returns a Galois array that you can use to perform or invert the discrete Fourier transform on a Galois vector

%In all cases, the vector being transformed must be a Galois vector of length 2m-1 in the field %GF(2m). The examples below illustrate the use of these functions. You can check, using the %isequal function, that y equals y1, z equals z1, and z equals x.
m = 4;
x = gf(randint(2^m-1,1,2^m),m); % A vector to transform
alph = gf(2,m);
dm = dftmtx(alph);
idm = dftmtx(1/alph);
y = dm*x; % Transform x using the result of dftmtx.
y1 = fft(x); % Transform x using fft.
z = idm*y; % Recover x using the result of dftmtx(1/alph).
z1 = ifft(y1); % Recover x using ifft.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %outputs


>> x

x = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal) %signal

Array elements =

7
14
12
7
0
13
7
9
12
14
11
2
6
14
14

>> length(x) %length of signal

ans =

15
>> dm
m = 4;
x = gf(randint(2^m-1,1,2^m),m); % A vector to transform
alph = gf(2,m);
dm = dftmtx(alph);
idm = dftmtx(1/alph);
y = dm*x; % Transform x using the result of dftmtx.
y1 = fft(x); % Transform x using fft.
z = idm*y; % Recover x using the result of dftmtx(1/alph).
z1 = ifft(y1); % Recover x using ifft.

dm = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

Columns 1 through 8

1 1 1 1 1 1 1 1
1 2 4 8 3 6 12 11
1 4 3 12 5 7 15 9
1 8 12 10 15 1 8 12
1 3 5 15 2 6 10 13
1 6 7 1 6 7 1 6
1 12 15 8 10 1 12 15
1 11 9 12 13 6 15 3
1 5 2 10 4 7 8 14
1 10 8 15 12 1 10 8
1 7 6 1 7 6 1 7
1 14 11 8 9 7 12 4
1 15 10 12 8 1 15 10
1 13 14 10 11 6 8 2
1 9 13 15 14 7 10 5

Columns 9 through 15

1 1 1 1 1 1 1
5 10 7 14 15 13 9
2 8 6 11 10 14 13
10 15 1 8 12 10 15
4 12 7 9 8 11 14
7 1 6 7 1 6 7
8 10 1 12 15 8 10
14 8 7 4 10 2 5
3 15 6 13 12 9 11
15 12 1 10 8 15 12
6 1 7 6 1 7 6
13 10 6 2 15 5 3
12 8 1 15 10 12 8
9 15 7 5 12 3 4
11 12 6 3 8 4 2

>> idm = dftmtx(1/alph);
>> idm = dftmtx(1/alph)

idm = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

Columns 1 through 8

1 1 1 1 1 1 1 1
1 9 13 15 14 7 10 5
1 13 14 10 11 6 8 2
1 15 10 12 8 1 15 10
1 14 11 8 9 7 12 4
1 7 6 1 7 6 1 7
1 10 8 15 12 1 10 8
1 5 2 10 4 7 8 14
1 11 9 12 13 6 15 3
1 12 15 8 10 1 12 15
1 6 7 1 6 7 1 6
1 3 5 15 2 6 10 13
1 8 12 10 15 1 8 12
1 4 3 12 5 7 15 9
1 2 4 8 3 6 12 11

Columns 9 through 15

1 1 1 1 1 1 1
11 12 6 3 8 4 2
9 15 7 5 12 3 4
12 8 1 15 10 12 8
13 10 6 2 15 5 3
6 1 7 6 1 7 6
15 12 1 10 8 15 12
3 15 6 13 12 9 11
14 8 7 4 10 2 5
8 10 1 12 15 8 10
7 1 6 7 1 6 7
4 12 7 9 8 11 14
10 15 1 8 12 10 15
2 8 6 11 10 14 13
5 10 7 14 15 13 9
>> y
y = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)
Array elements =

12
11
12
5
2
4
0
4
6
14
7
1
6
1
2

>> y1

y1 = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

12
11
12
5
2
4
0
4
6
14
7
1
6
1
2

>> y-y1 %difference between "F. transforms by 2 different methods.

ans = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

>> z

z = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

7
14
12
7
0
13
7
9
12
14
11
2
6
14
14

>> z1

z1 = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

7
14
12
7
0
13
7
9
12
14
11
2
6
14
14

>> z-z1 %difference between original signals by 2 diff. methods.

ans = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

>> amen amen amen
Wednesday, April 15, 2009

Polynomials over Galois Fields


You can use Galois vectors to represent polynomials in an indeterminate quantity x, with coefficients in a Galois field. Form the representation by listing the coefficients of the polynomial in a vector in order of descending powers of x. For example, the vector
gf([2 1 0 3],4)


represents the polynomial Ax3 + 1x2 + 0x + (A+1), where

A is a primitive element in the field GF(24).

x is the indeterminate quantity in the polynomial.

You can then use such a Galois vector to perform arithmetic with, evaluate, and find roots of polynomials. You can also find minimal polynomials of elements of a Galois field.

Wednesday, April 15, 2009
Communications Toolbox
Addition and Subtraction of Polynomials

To add and subtract polynomials, use + and - on equal-length Galois vectors that represent the polynomials. If one polynomial has lower degree than the other, then you must pad the shorter vector with zeros at the beginning so that the two vectors have the same length.

The example below shows how to add a degree-one and a degree-two polynomial.
lin = gf([4 2],3); % A^2 x + A, which is linear in x
linpadded = gf([0 4 2],3); % The same polynomial, zero-padded
quadr = gf([1 4 2],3); % x^2 + A^2 x + A, which is quadratic in x
% Can't do lin + quadr because they have different vector lengths.
sumpoly = [0, lin] + quadr; % Sum of the two polynomials
sumpoly2 = linpadded + quadr; % The same sum.


%outputs

>> lin

lin = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)

Array elements =

4 2

>> linpadded

linpadded = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)

Array elements =

0 4 2

>> quadr

quadr = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)

Array elements =

1 4 2

>> sumpoly

sumpoly = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)

Array elements =

1 0 0

>> sumpoly2

sumpoly2 = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal)

Array elements =

1 0 0
Wednesday, April 15, 2009
Simulink
Polynomial


Perform evaluation of polynomial coefficients on input values
Library


Math Operations
Description
block

The Polynomial block uses a coefficients parameter to evaluate a real polynomial for the input value.

You define a set of polynomial coefficients in the form accepted by the MATLAB polyval command. The block then calculates P(u) at each time step for the input u. Inputs and coefficients must be real.
Data Type Support


The Polynomial block accepts real signals of types double or single. The Polynomial coefficients parameter must be of the same type as the inputs. The output data type is set to the input data type.
polynomial coefficients


Values are in coefficients of a polynomial in MATLAB polyval form, with the first coefficient representing x^N, then decreasing in order until the last coefficient, which represents the constant for the polynomial. See polyval in the MATLAB documentation for more information.

Wednesday, April 15, 2009



%Communications Toolbox
%Evaluating Polynomials
%15 april 2009
%sayanyein

%To evaluate a polynomial at an element of a Galois field, use polyval.
%It behaves like the ordinary MATLAB polyval function when given exactly two input arguments. The example below evaluates a polynomial at several elements in a field and checks the results using .^ and .* in the field.

m = 4;
apoly = gf([4 5 3],m); % A^2 x^2 + (A^2 + 1) x + (A + 1)
x0 = gf([0 1 2],m); % Points at which to evaluate the polynomial
y = polyval(apoly,x0);

a = gf(2,m); % Primitive element of the field, corresponding to A.
y2 = a.^2.*x0.^2 + (a.^2+1).*x0 + (a+1) ;% Check the result.


%The output is below.
%y = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

%Array elements =

% 3 2 10


%y2 = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

%Array elements =

% 3 2 10



%The first element of y evaluates the polynomial at 0 and, therefore,
%returns the polynomial's constant term of 3
%outputs
To get started, select MATLAB Help or Demos from the Help menu.


a = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

2
y

y = GF(2^4) array. Primitive polynomial = D
%1 nov. 2009

hind parts of lion or a big inverted begging bowl!

hind parts of lion or a big inverted begging bowl!
1 nov. 2009
Soethein-to-rd
Humour Editor,
Reader 's Digest Asia,
Editorial Department,
Singapore Post Centre,PO Box272,Singapore 914010.

hind parts of lion or a big inverted begging bowl!
Dear Editor,
We are on a pilgrimage trip from Mandalay to a small village –Mingum(where the world's largest ringing bell is situated). It stands on the bank of Irrawaddy river .
Beside the big bell , there is an unfinished gigantic pagoda – only the base had been
completed .
In front ,there are two chinthes(Burmese mythical lions)guarding the
entrance of the big pagoda .
Due to an earthquake and unproportioned built,both of them had been crumbled down to the ground. Only the hind parts remain to this day.
They are almost three stories high and were blackened with moss and lichens. A professor of mine mistaken this (hind parts of the mythical lion )with a big inverted begging bowl,seen from a distance.
Sicerely yours,
Soee Theynn,
#65,Tit Tar Win,
B/W 27 & 28-and 83& 84 Street,
Chan Aye Thar Zan T/S,
Kennedy Space Villa,
Zegyo – Mandalay,
Union of Myanmar.
asia.rd@readersdigest.com
soethein1938@gmail.com
khin mg bo ,58 st,,no. 93,
mother home
you are a guru, but u can not tolerate people;irritated very easily.
km bo,
with love.

computer vocabulary / bandwidth

computer vocabulary / bandwidth
1 nov. 2009

bandwidth
n. 1. The difference between the highest and lowest frequencies that an analog communications system can pass as measured in Hertz (Hz) or cycles per second. For example, a telephone accommodates a bandwidth of 3,000 Hz: the difference between the lowest (300 Hz) and highest (3,300 Hz) frequencies it can carry. 2. The data transfer capacity, or speed of transmission, of a digital communications system as measured in bits per second (bps).
bps
n. Short for bits per second. The measure of transmission speed used in relations to networks and communication lines. Although bps represents the basic unit of measure, networks and communications devices, such as modems, are so fast that speeds are usually given in multiples of bps-Kbps (kilobits, or thousands of bits, per second), Mbps (megabits, or millions of bits, per second), and Gbps (gigabits, or billions of bits, per second).. Speed in bps is not the same as the baud rate for a modem. See also baud rate.

wavelet / short notes /1 november 2009

wavelet
short notes on wavelet
sayaNyein 25 october 2009

The MAT-files are located in the directory toolbox/wavelet/wavedemo
Wavelet toolbox-wavelet applications -wavelets in action-Illustrated examples.
History of Wavelets
From an historical point of view, wavelet analysis is a new method, though its mathematical underpinnings date back to the work of Joseph Fourier in the nineteenth century. Fourier laid the foundations with his theories of frequency analysis, which proved to be enormously important and influential.
The attention of researchers gradually turned from frequency-based analysis to scale-based analysis when it started to become clear that an approach measuring average fluctuations at different scales might prove less sensitive to noise.
The first recorded mention of what we now call a "wavelet" seems to be in 1909, in a thesis by Alfred Haar.
The concept of wavelets in its present theoretical form was first proposed by Jean Morlet and the team at the Marseille Theoretical Physics Center working under Alex Grossmann in France.
The methods of wavelet analysis have been developed mainly by Y. Meyer and his colleagues, who have ensured the methods' dissemination. The main algorithm dates back to the work of Stephane Mallat in 1988. Since then, research on wavelets has become international. Such research is particularly active in the United States, where it is spearheaded by the work of scientists such as Ingrid Daubechies, Ronald Coifman, and Victor Wickerhauser.
Barbara Burke Hubbard describes the birth, the history, and the seminal concepts in a very clear text. See "The World According to Wavelets," A.K. Peters, Wellesley, 1996.
The wavelet domain is growing up very quickly. A lot of mathematical papers and practical trials are published every moment.
Wavelet Packet Analysis
The wavelet packet method is a generalization of wavelet decomposition that offers a richer range of possibilities for signal analysis.

In wavelet analysis, a signal is split into an approximation and a detail. The approximation is then itself split into a second-level approximation and detail, and the process is repeated. For an n-level decomposition, there are n+1 possible ways to decompose or encode the signal.
In wavelet packet analysis, the details as well as the approximations can be split.
This yields more than different ways to encode the signal. This is the wavelet packet decomposition tree.
Haar
Any discussion of wavelets begins with Haar wavelet, the first and simplest. Haar wavelet is discontinuous, and resembles a step function. It represents the same wavelet as Daubechies db1. See Haar for more detail.
Daubechies
Ingrid Daubechies, one of the brightest stars in the world of wavelet research, invented what are called compactly supported orthonormal wavelets -- thus making discrete wavelet analysis practicable.
The names of the Daubechies family wavelets are written dbN, where N is the order, and db the "surname" of the wavelet. The db1 wavelet, as mentioned above, is the same as Haar wavelet. Here are the wavelet functions psi of the next nine members of the family:
Biorthogonal
This family of wavelets exhibits the property of linear phase, which is needed for signal and image reconstruction. By using two wavelets, one for decomposition (on the left side) and the other for reconstruction (on the right side) instead of the same single one, interesting properties are derived.
Wavelet Analysis
Wavelet analysis represents the next logical step: a windowing technique with variable-sized regions. Wavelet analysis allows the use of long time intervals where we want more precise low-frequency information, and shorter regions where we want high-frequency information
--------
You may have noticed that wavelet analysis does not use a time-frequency region, but rather a time-scale region. For more information about the concept of scale and the link between scale and frequency, see How to Connect Scale to Frequency?.

What Can Wavelet Analysis Do?
One major advantage afforded by wavelets is the ability to perform local analysis -- that is, to analyze a localized area of a larger signal.
Consider a sinusoidal signal with a small discontinuity -- one so tiny as to be barely visible. Such a signal easily could be generated in the real world, perhaps by a power fluctuation or a noisy switch.
Wavelet analysis is capable of revealing aspects of data that other signal analysis techniques miss, aspects like trends, breakdown points, discontinuities in higher derivatives, and self-similarity. Furthermore, because it affords a different view of data than those presented by traditional techniques, wavelet analysis can often compress or de-noise a signal without appreciable degradation.
What Is Wavelet Analysis?
Now that we know some situations when wavelet analysis is useful, it is worthwhile asking "What is wavelet analysis?" and even more fundamentally, "What is a wavelet?"
A wavelet is a waveform of effectively limited duration that has an average value of zero.
Compare wavelets with sine waves, which are the basis of Fourier analysis. Sinusoids do not have limited duration -- they extend from minus to plus infinity. And where sinusoids are smooth and predictable, wavelets tend to be irregular and asymmetric.
Fourier analysis consists of breaking up a signal into sine waves of various frequencies. Similarly, wavelet analysis is the breaking up of a signal into shifted and scaled versions of the original (or mother) wavelet.
Just looking at pictures of wavelets and sine waves, you can see intuitively that signals with sharp changes might be better analyzed with an irregular wavelet than with a smooth sinusoid, just as some foods are better handled with a fork than a spoon.
It also makes sense that local features can be described better with wavelets that have local extent.
Number of Dimensions

Thus far, we've discussed only one-dimensional data, which encompasses most ordinary signals. However, wavelet analysis can be applied to two-dimensional data (images) and, in principle, to higher dimensional data.
This toolbox uses only one- and two-dimensional analysis techniques.
The Discrete Wavelet Transform
Calculating wavelet coefficients at every possible scale is a fair amount of work, and it generates an awful lot of data. What if we choose only a subset of scales and positions at which to make our calculations?
It turns out, rather remarkably, that if we choose scales and positions based on powers of two -- so-called dyadic scales and positions -- then our analysis will be much more efficient and just as accurate. We obtain such an analysis from the discrete wavelet transform (DWT). For more information on DWT, see Algorithms.
An efficient way to implement this scheme using filters was developed in 1988 by Mallat (see [Mal89] in References). The Mallat algorithm is in fact a classical scheme known in the signal processing community as a two-channel subband coder (see page 1 of the book Wavelets and Filter Banks, by Strang and Nguyen [StrN96]).
This very practical filtering algorithm yields a fast wavelet transform -- a box into which a signal passes, and out of which wavelet coefficients quickly emerge. Let's examine this in more depth.
Nuance fine distinction, trace, tinge.
One-Stage Filtering: Approximations and Details
For many signals, the low-frequency content is the most important part. It is what gives the signal its identity. The high-frequency content, on the other hand, imparts flavor or nuance. Consider the human voice. If you remove the high-frequency components, the voice sounds different, but you can still tell what's being said. However, if you remove enough of the low-frequency components, you hear gibberish.
In wavelet analysis, we often speak of approximations and details. The approximations are the high-scale, low-frequency components of the signal. The details are the low-scale, high-frequency components.
The filtering process, at its most basic level, looks like this---

the original signal, S, passes through two complementary filters and emerges as two signals.
Unfortunately, if we actually perform this operation on a real digital signal, we wind up with twice as much data as we started with. Suppose, for instance, that the original signal S consists of 1000 samples of data. Then the resulting signals will each have 1000 samples, for a total of 2000.
These signals A and D are interesting, but we get 2000 values instead of the 1000 we had. There exists a more subtle way to perform the decomposition using wavelets. By looking carefully at the computation, we may keep only one point out of two in each of the two 2000-length samples to get the complete information. This is the notion of downsampling. We produce two sequences called cA and cD.
The process on the right, which includes downsampling, produces DWT coefficients.
To gain a better appreciation of this process, let's perform a one-stage discrete wavelet transform of a signal. Our signal will be a pure sinusoid with high-frequency noise added to it.
Here is our schematic diagram with real signals inserted into it.
The MATLAB code needed to generate s, cD, and cA is
s = sin(20.*linspace(0,pi,1000)) + 0.5.*rand(1,1000);
[cA,cD] = dwt(s,'db2');
where db2 is the name of the wavelet we want to use for the analysis.
Notice that the detail coefficients cD are small and consist mainly of a high-frequency noise, while the approximation coefficients cA contain much less noise than does the original signal.
[length(cA) length(cD)]
ans =
501 501
You may observe that the actual lengths of the detail and approximation coefficient vectors are slightly more than half the length of the original signal. This has to do with the filtering process, which is implemented by convolving the signal with a filter. The convolution "smears" the signal, introducing several extra samples into the result.
%The MATLAB code needed to generate s, cD, and cA is
s = sin(20.*linspace(0,pi,1000)) + 0.5.*rand(1,1000);

[cA,cD] = dwt(s,'db2');
Wavelet Toolbox
Introduction to Wavelet Analysis
Each example is followed by a discussion of the usefulness of wavelet analysis for the particular application area under consideration.
Use the graphical interface tools to follow along: From the MATLAB command line, type
wavemenu
Click on Wavelets 1-D (or another tool as appropriate). Load the sample analysis by selecting the appropriate submenu item from FileExample Analysis.
Feel free to explore on your own -- use the different options provided in the graphical interface to look at different components of the signal, to compress or de-noise the signal, to examine signal statistics, or to zoom in and out on different signal features.
If you want, try loading the corresponding MAT-file from the MATLAB command line, and use the Wavelet Toolbox functions to further investigate the sample signals. The MAT-files are located in the directory toolbox/wavelet/wavedemo.
There are also other signals in the wavedemo directory that you can analyze on your own.
Detecting Discontinuities and Breakdown Points I
The purpose of this example is to show how analysis by wavelets can detect the exact instant when a signal changes. The discontinuous signal consists of a slow sine wave abruptly followed by a medium sine wave.
The first- and second-level details (D1 and D2) show the discontinuity most clearly, because the rupture contains the high-frequency part. Note that if we were only interested in identifying the discontinuity, db1 would be a more useful wavelet to use for the analysis than db5.
The discontinuity is localized very precisely: only a small domain around time = 500 contains any large first- or second-level details.
Here is a noteworthy example of an important advantage of wavelet analysis over Fourier. If the same signal had been analyzed by the Fourier transform, we

would not have been able to detect the instant when the signal's frequency changed, whereas it is clearly observable here.
Details D3 and D4 contain the medium sine wave. The slow sine is clearly isolated in approximation A5, from which the higher-frequency information has been filtered.
Discussion
The deterministic part of the signal may undergo abrupt changes such as a jump, or a sharp change in the first or second derivative. In image processing, one of the major problems is edge detection, which also involves detecting abrupt changes. Also in this category, we find signals with very rapid evolutions such as transient signals in dynamic systems.
The main characteristic of these phenomena is that the change is localized in time or in space.
The purpose of the analysis is to determine
The site of the change (e.g., time or position)
The type of change (a rupture of the signal, or an abrupt change in its first or second derivative)
The amplitude of the change
The local aspects of wavelet analysis are well adapted for processing this type of event, as the processing scales are linked to the speed of the change.
Guidelines for Detecting Discontinuities
Short wavelets are often more effective than long ones in detecting a signal rupture. In the initial analysis scales, the support is small enough to allow fine analysis. The shapes of discontinuities that can be identified by the smallest wavelets are simpler than those that can be identified by the longest wavelets. Therefore, to identify A signal discontinuity, use the haar wavelet A rupture in the j-th derivative, select a sufficiently regular wavelet with at least j vanishing moments. (See Detecting Discontinuities and Breakdown Points II.)
The presence of noise, which is after all a fairly common situation in signal processing, makes identification of discontinuities more complicated. If the first levels of the decomposition can be used to eliminate a large part of the noise, the rupture is sometimes visible at deeper levels in the decomposition.
Check, for example, the sample analysis FileExample AnalysisBasic Signalsramp + white noise (MAT-file wnoislop). The rupture is visible in the level-six approximation (A6) of this signal.

Detecting Discontinuities and Breakdown Points II
The purpose of this example is to show how analysis by wavelets can detect a discontinuity in one of a signal's derivatives. The signal, while apparently a single smooth curve, is actually composed of two separate exponentials that are connected at time = 500. The discontinuity occurs only in the second derivative, at time = 500.
**********************
We have zoomed in on the middle part of the signal to show more clearly what happens around time = 500. The details are high only in the middle of the signal and are negligible elsewhere. This suggests the presence of high-frequency information -- a sudden change or discontinuity -- around time = 500.
Discussion
Regularity can be an important criterion in selecting a wavelet. We have chosen to use db4, which is sufficiently regular for this analysis. Had we chosen the haar wavelet, the discontinuity would not have been detected. If you try repeating this analysis using haar at level two, you'll notice that the details are equal to zero at time = 500.
Note that to detect a singularity, the selected wavelet must be sufficiently regular, which implies a longer filter impulse response.
See the sections Frequently Asked Questions and Wavelet Families: Additional Discussion for a discussion of the mathematical meaning of regularity and a comparison of the regularity of various wavelets.
Detecting Long-Term Evolution
The purpose of this example is to show how analysis by wavelets can detect the overall trend of a signal. The signal in this case is a ramp obscured by "colored" (limited-spectrum) noise. (We have zoomed in along the x-axis to avoid showing edge effects.)
There is so much noise in the original signal, s, that its overall shape is not apparent upon visual inspection. In this level-6 analysis, we note that the trend becomes more and more clear with each approximation, A1 to A6. Why is this?

The trend represents the slowest part of the signal. In wavelet analysis terms, this corresponds to the greatest scale value. As the scale increases, the resolution decreases, producing a better estimate of the unknown trend.
Another way to think of this is in terms of frequency. Successive approximations possess progressively less high-frequency information. With the higher frequencies removed, what's left is the overall trend of the signal.
Discussion
Wavelet analysis is useful in revealing signal trends, a goal that is complementary to the one of revealing a signal hidden in noise. It's important to remember that the trend is the slowest part of the signal. If the signal itself includes sharp changes, then successive approximations look less and less similar to the original signal.
Consider the demo analysis FileExample AnalysisBasic SignalsStep signal (MAT-file wstep.mat). It is instructive to analyze this signal using the Wavelet 1-D tool and see what happens to the successive approximations. Try it.
Detecting Self-Similarity
The purpose of this example is to show how analysis by wavelets can detect a self-similar, or fractal, signal. The signal here is the Koch curve -- a synthetic signal that is built recursively.
This analysis was performed with the Continuous Wavelet 1-D graphical tool. A repeating pattern in the wavelet coefficients plot is characteristic of a signal that looks similar on many scales.
Wavelet Coefficients and Self-Similarity
From an intuitive point of view, the wavelet decomposition consists of calculating a "resemblance index" between the signal and the wavelet. If the index is large, the resemblance is strong, otherwise it is slight. The indices are the wavelet coefficients.
If a signal is similar to itself at different scales, then the "resemblance index" or wavelet coefficients also will be similar at different scales. In the coefficients plot, which shows scale on the vertical axis, this self-similarity generates a characteristic pattern.
Discussion
The work of many authors and the trials that they have carried out suggest that wavelet decomposition is very well adapted to the study of the fractal properties of signals and images.

When the characteristics of a fractal evolve with time and become local, the signal is called a multifractal. The wavelets then are an especially suitable tool for practical analysis and generation.
Wednesday, March 25, 2009
Example 14: A Real Electricity Consumption Signal
Analyzing wavelet: db3
Decomposition levels: 5
The series presents a peak in the center, followed by two drops, a shallow drop, and then a considerably weaker peak.
The details for levels 1 and 2 are of the same order of magnitude and give a good expression of the local irregularities caused by the noise. The detail for level 3 presents high values in the beginning and at the end of the main peak, thus allowing us to locate the corresponding drops. The detail D4 shows coarser morphological aspects for the series (i.e., three successive peaks). This fits the shape of the curve remarkably well, and includes the essential signal components for periods of less than 32 time-units. The approximations show this effect clearly: A1 and A2 bear a strong resemblance; A3 forms a reasonably accurate approximation of the original signal. A look at A4, however, shows that a considerable amount of information has been lost.
In this case, as a conclusion, the multiscale aspect is the most interesting and the most significant feature: the essential components of the electrical signal used to complete the description at 32 time-units (homogeneous to A5) are the components with a period between 8 and 16 time-units.
Example 1: A Sum of Sines
Analyzing wavelet: db3
Decomposition levels: 5
The signal is composed of the sum of three sines: slow, medium, and rapid. With regard to the sampling period equal to 1, the periods are approximately 200, 20, and 2 respectively. We should, therefore, see this later period in D1, the medium sine in D4, and the slow sine in A4. The slight differences that can be observed on the decompositions can be attributed to the sampling period. The scale of the approximation charts is 2, 4, or 10 times larger than that of the details. D1 contains

primarily the components whose period is situated between 1 and 2 (i.e., the rapid sine), but this period is not visible at the scale that is used for the graph. Zooming in on D1 reveals that each "belly" is composed of 10 oscillations, and can be used to estimate the period. We find that the period is close to 2. D2 is very small. This is also seen in the approximations: the first two resemble one another, since .
The detail D3 and, to an even greater extent, the detail D4 contain the medium sine. We notice that there is a breakdown between approximations 3 and 4.
Approximations A1 to A3 can be used to estimate the period of the medium sine. Now, only the slow sine, which appears in A4, remains to be determined. The distance between two successive maximums is equal to 200, which is the period of the slow sine. This latter sine is still visible in A5, but will disappear from the approximation and move into the details at level 8.
Example 2: A Frequency Breakdown
Analyzing wavelet: db5
Decomposition levels: 5
The signal is formed of a slow sine and a medium sine, on either side of 500. These two sines are not connected in a continuous manner: D1 and D2 can be used to detect this discontinuity. It is localized very precisely: only a small domain around 500 contains large details. This is because the rupture contains the high-frequency part; the frequencies in the rest of the signal are not as high. It should be noted that if we are interested only in identifying the discontinuity, db1 is more useful than db5.
D3 and D4 contain the medium sine as in the previous analysis. The slow sine appears clearly alone in A5. It is more regular than in the s1 analysis, since db5 is more regular than db3. If the same signal had been analyzed by the Fourier transform, we would not have been able to detect the instant corresponding to the signal's frequency change, whereas it is clearly observable here.
Example 3: Uniform White Noise
Analyzing wavelet: db3
Decomposition levels: 5
At all levels we encounter noise-type signals that are clearly irregular. This is because all the frequencies carry the same energy. The variances, however, decrease regularly between one level and the next as can be seen reading the detail chart (on the right) and the approximations (on the left).
The variance decreases two-fold between one level and the next, i.e., variance(Dj) = variance(Dj - 1) / 2. Lastly, it should be noted that the details and approximations are not white noise, and that these signals are increasingly interdependent as the

resolution decreases. On the other hand, the wavelet coefficients are random, noncorrelated variables. This property is not evident on the reconstructed signals shown here, but it can be guessed at from the representation of the coefficients.
Wavelet toolbox-wavelet applications -wavelets in action-Illustrated examples.
Example 1: A Sum of Sines
Analyzing wavelet: db3
Decomposition levels: 5
The signal is composed of the sum of three sines: slow, medium, and rapid. With regard to the sampling period equal to 1, the periods are approximately 200, 20, and 2 respectively. We should, therefore, see this later period in D1, the medium sine in D4, and the slow sine in A4. The slight differences that can be observed on the decompositions can be attributed to the sampling period. The scale of the approximation charts is 2, 4, or 10 times larger than that of the details. D1 contains primarily the components whose period is situated between 1 and 2 (i.e., the rapid sine), but this period is not visible at the scale that is used for the graph. Zooming in on D1 reveals that each "belly" is composed of 10 oscillations, and can be used to estimate the period. We find that the period is close to 2. D2 is very small. This is also seen in the approximations: A1=A2+D2.
the first two resemble one another, since .
The detail D3 and, to an even greater extent, the detail D4 contain the medium sine. We notice that there is a breakdown between approximations 3 and 4.
Approximations A1 to A3 can be used to estimate the period of the medium sine. Now, only the slow sine, which appears in A4, remains to be determined. The distance between two successive maximums is equal to 200, which is the period of the slow sine. This latter sine is still visible in A5, but will disappear from the approximation and move into the details at level 8.
Wavelet toolbox-wavelet applications -wavelets in action-Illustrated examples.
Example 2: A Frequency Breakdown
Analyzing wavelet: db5
Decomposition levels: 5
The signal is formed of a slow sine and a medium sine, on either side of 500. These two sines are not connected in a continuous manner: D1 and D2 can be used to detect this discontinuity. It is localized very precisely: only a small domain around 500 contains large details. This is because the rupture contains the high-frequency part; the frequencies in the rest of the signal are not as high. It should be noted that if we are interested only in identifying the discontinuity, db1 is more useful than db5.
D3 and D4 contain the medium sine as in the previous analysis. The slow sine appears clearly alone in A5. It is more regular than in the s1 analysis, since db5 is more regular than db3. If the same signal had been analyzed by the Fourier

Transform, we would not have been able to detect the instant corresponding to the signal's frequency change, whereas it is clearly observable here.
Wavelet toolbox-wavelet applications -wavelets in action-Illustrated examples.
Example 3: Uniform White Noise
Analyzing wavelet: db3
Decomposition levels: 5
At all levels we encounter noise-type signals that are clearly irregular. This is because all the frequencies carry the same energy. The variances, however, decrease regularly between one level and the next as can be seen reading the detail chart (on the right) and the approximations (on the left).
The variance decreases two-fold between one level and the next, i.e., variance(Dj) = variance(Dj - 1) / 2. Lastly, it should be noted that the details and approximations are not white noise, and that these signals are increasingly interdependent as the resolution decreases. On the other hand, the wavelet coefficients are random, noncorrelated variables. This property is not evident on the reconstructed signals shown here, but it can be guessed at from the representation of the coefficients.
Wavelet toolbox-wavelet applications -wavelets in action-Illustrated examples.
Example 6: A Step Signal
Analyzing wavelet: db2
Decomposition levels: 5
In this case, we are faced with the simplest example of a rupture (i.e., a step). The time instant when the jump occurs is equal to 500. The break is detected at all levels, but it is obviously detected with greater precision in the higher resolutions (levels 1 and 2) than in the lower ones (levels 4 and 5). It is very precisely localized at level 1, where only a very small zone around the jump time can be seen.
It should be noted that the reconstructed details are primarily composed of the basic wavelet represented in the initial time.
Furthermore, the rupture is more precisely localized when the wavelet corresponds to a short filter.
Wavelet toolbox-wavelet applications -wavelets in action-Illustrated examples.
Wednesday, March 25, 2009
Example 7: Two Proximal Discontinuities
Analyzing wavelet: db2 and db7
Decomposition levels: 5
The signal is formed of two straight lines with identical slopes, extending across a very short plateau. On the initial signal, the plateau is in fact barely visible to the naked eye. Two analyses are thus carried out: one on a well localized wavelet with the short filter (db2, shown on the left side of the figure); and the other on a wavelet having a longer filter (db7, shown on the right side of the figure).

In both analyses, the plateau is detected clearly. With the exception of a fairly limited domain, D1 is equal to zero. The regularity of the signal in the plateau, however, is clearly distinguished for db2 (for which plateau beginning and end time are distinguished), whereas for db7 both discontinuities are fused and only the entire plateau can be said to be visible.
This example suggests that the selected wavelets should be associated with short filters to distinguish proximal discontinuities of the first derivative. A look at the other detail levels again shows the lack of precision when detecting at low resolutions. The wavelet filters the straight line and analyzes the discontinuities.
Wednesday, March 25, 2009
Example 8: A Second-Derivative Discontinuity
Analyzing wavelet: db1 and db4
Decomposition levels: 2
This figure shows that the regularity can be an important criterion in selecting a wavelet. The basic function is composed of two exponentials that are connected at 0, and the analyzed signal is the sampling of the continuous function with increments of 10-3. The sampled signal is analyzed using two different wavelets: db1, which is insufficiently regular (shown on the left side of the figure); and db4, which is sufficiently regular (shown on the right side of the figure).
Looking at the figure on the left we notice that the singularity has not been detected in the extent that the details are equal to 0 at 0. The black areas correspond to very rapid oscillations of the details. These values are equal to the difference between the function and an approximation using a constant function. Close to 0, the slow decrease of the details absolute values followed by a slow increase is due to the fact that the function derivative is zero and continuous at 0. The value of the details is very small (close to 10-3 for db1 and 10-4 for db4) since the signal is very smooth and does not contain any high frequency. This value is even smaller for db4, since the wavelet is more regular than db1.
However, with db4 (right side of the figure), the discontinuity is well detected: the details are high only close to 0, and are 0 everywhere else. This is the only element that can be derived from the analysis. In this case, as a conclusion, we notice that the selected wavelet must be sufficiently regular, which implies a longer filter impulse response to detect the singularity.
Example 9: A Ramp + White Noise
Analyzing wavelet: db3
Decomposition levels: 6

The signal is built from a trend plus noise. The trend is a slow linear rise from 0 to 3, up to t=500, and becoming constant afterwards. The noise is a uniform zero-mean white noise, varying between -0.5 and 0.5 (see the analyzed signal b1).
Looking at the figure, in the chart on the right, we again find the decomposition of noise in the details. In the charts on the left, the approximations form increasingly precise estimates of the ramp with less and less noise. These approximations are quite acceptable from level 3, and the ramp is well reconstructed at level 6.
We can, therefore, separate the ramp from the noise. Although the noise affects all scales, its effect decreases sufficiently quickly for the low-resolution approximations to restore the ramp. It should also be noted that the breakdown point of the ramp is shown with good precision. This is due to the fact that the ramp is recovered at too low a resolution.
The uniform noise indicates that the ramp might be best estimated using half sums for the higher and lower portions of the signal. This approach is not applicable for other noises.
xample 10: A Ramp + Colored Noise
Analyzing wavelet: db3
Decomposition levels: 6
The signal is built in the same manner as in Example 9: A Ramp + White Noise, using a trend plus a noise. The trend is a slow linear increase from 0 to 1, up to t=500. Beyond this time, the value remains constant. The noise is a zero mean AR(3) noise, varying between -3 and 3 (see the analyzed signal b2). The scale of the noise is indeed six times greater than that of the ramp. At first glance, the situation seems a little bit less favorable than in the previous example, in terms of the separation between the ramp and the noise. This is actually a misconception, since the two signal components are more precisely separated in frequency.
Looking at the figure, the charts on the right show the detail decomposition of the colored noise. The charts on the left show a decomposition that resembles the one in the previous analysis. Starting at level 3, the curves provide satisfactory approximations of the ramp.
%is this creation
%Example
I = imread('eight.tif');
J = imnoise(I,'salt & pepper',0.02);
imshow(I)
%figure, imshow(J)
%'gaussian' %Gaussian white noise with constant mean and variance
%'localvar' %Zero-mean Gaussian white noise with an intensity-dependent variance
%'poisson' %Poisson noise
%'salt & pepper' %On and off pixels
%'speckle' %Multiplicative noise.
Thursday, April 02, 2009
To contd.Wavelet toolbox-Advanced concepts-general concepts
General Concepts

This section presents a brief overview of wavelet concepts, focusing mainly on the orthogonal wavelet case. It includes the following sections: Wavelets: A New Tool for Signal Analysis Wavelet Decomposition: A Hierarchical Organization
Finer and Coarser Resolutions
Wavelet Shapes Wavelets and Associated Families
Wavelet Transforms:
Continuous and Discrete
Local and Global Analysis Synthesis:
An Inverse Transform Details and Approximations.
Wavelet Toolbox
Wavelets: A New Tool for Signal Analysis
Wavelet analysis consists of decomposing a signal or an image into a hierarchical set of approximations and details. The levels in the hierarchy often correspond to those in a dyadic scale.
From the signal analyst's point of view, wavelet analysis is a decomposition of the signal on a family of analyzing signals, which is usually an "orthogonal function method.
From an algorithmic point of view, wavelet analysis offers a harmonious compromise between decomposition and smoothing techniques.
Wavelet Toolbox
Wavelet Decomposition: A Hierarchical Organization
Unlike conventional techniques, wavelet decomposition produces a family of hierarchically organized decompositions. The selection of a suitable level for the hierarchy will depend on the signal and experience. Often the level is chosen based on a desired low-pass cutoff frequency.
At each level j, we build the j-level approximation Aj, or approximation at level j, and a deviation signal called the j-level detail Dj, or detail at level j. We can consider the original signal as the approximation at level 0, denoted by A0. The words approximation and detail are justified by the fact that A1 is an approximation of A0 taking into account the low frequencies of A0, whereas the detail D1 corresponds to the high frequency correction. Among the figures presented in the section Reconstructing Approximations and Details, one of them graphically represents this hierarchical decomposition.
One way of understanding this decomposition consists of using an optical comparison. Successive images A1, A2, A3 of a given object are built. We use the same type of photographic devices, but with increasingly poor resolution. The images are successive approximations; one detail is the discrepancy between two

successive images. Image A2 is, therefore, the sum of image A4 and intermediate details D4, D3.
A2=A3+D3=A4+D4+D3.
Wavelet Toolbox
Finer and Coarser Resolutions
The organizing parameter, the scale a, is related to level j by a = 2^j . If we define resolution as 1/a, then the resolution increases as the scale decreases. The greater the resolution, the smaller and finer are the details that can be accessed.
j 10 9... 2 1 0 -1 -2
Scale 1024 512... 4 2 1 ½ 1/4
Resolution 1/2^10 ½^9...1/4 1/2 1 2 4
From a technical point of view, the size of the revealed details for any j is proportional to the size of the domain in which the wavelet or analyzing function of the variable x,
Xi(x/a)
is not too close to 0.
To continue-wavelet shapesThursday, April 02, 2009
Wavelet Toolbox
Wavelet Shapes
One-dimensional analysis is based on one scaling function Fi and one wavelet Zi . Two-dimensional analysis (on a square or rectangular grid) is based on one scaling function Fi(x1,x2) and three wavelets.
The following figure shows Fi and Zi for each wavelet, except the Morlet wavelet and the Mexican hat, for which Fi does not exist. All the functions decay quickly to zero. The Haar wavelet is the only noncontinuous function with three points of discontinuity (0, 0.5, 1). The Fi functions oscillate more than associated Zi functions. coif2 exhibits some angular points; db6 and sym6 are quite smooth. The Morlet and Mexican hat wavelets are symmetrical.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Wavelet Toolbox
Wavelets and Associated Families
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Wavelet Toolbox
Wavelet Transforms: Continuous and Discrete

The wavelet transform of a signal s is the family C(a,b), which depends on two indices a and b. The set to which a and b belong is given below in the table. The studies focus on two transforms: Continuous transform Discrete transform
From an intuitive point of view, the wavelet decomposition consists of calculating a "resemblance index" between the signal and the wavelet located at position b and of scale a. If the index is large, the resemblance is strong, otherwise it is slight. The indexes C(a,b) are called coefficients.
We define the coefficients in the following table. We have two types of analysis at our disposal
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Using a redundant representation close to the so-called continuous analysis, instead of a nonredundant discrete time-scale representation, can be useful for analysis purposes. The nonredundant representation is associated with an orthonormal basis, whereas the redundant representation uses much more scale and position values than a basis. For a classical fractal signal, the redundant methods are quite accurate.
Graphic representation of discrete analysis: (in the middle of Figure 6-6, Continuous Versus Discrete Transform) time is on the abscissa and on the ordinate the scale a is dyadic: 21, 22, 23, 24, and 25 (from the bottom to the top), levels are 1, 2, 3, 4, and 5. Each coefficient of level k is repeated 2k times.
Graphic representation of continuous analysis: (at the bottom of Figure 6-6, Continuous Versus Discrete Transform) time is on the abscissa and on the ordinate the scale varies almost continuously between 21 and 25 by step 1 (from the bottom to the top). Keep in mind that when a scale is small, only small details are analyzed, as in a geographical map.
Wednesday, April 08, 2009 6:08 AM
To continue-Wavelets-Advanced concepts-general concepts-
Wavelet Toolbox
Dealing with Border Distortion
Classically, the DWT is defined for sequences with length of some power of 2, and different ways of extending samples of other sizes are needed. Methods for extending the signal include zero-padding, smooth padding, periodic extension, and boundary value replication (symmetrization).
The basic algorithm for the DWT is not limited to dyadic length and is based on a simple scheme: convolution and downsampling. As usual, when a convolution is performed on finite-length signals, border distortions arise.
%%%%%%%%%%%%%%%
Basic two-dimensional objects.
A0 Approximation at level 0
Approximation at level k

Dk Details at level k
cAk, Approximation coefficients at level k
cDk Detail coefficients at level k
the horizontal, vertical, and diagonal details at level k.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Two-Dimensional Analysis Using the Command Line
Note Instead of directly using image(I) to visualize the image I, we use image(wcodemat(I)), which displays a rescaled version of I leading to a clearer presentation of the details and approximations (see wcodemat reference page)
$$$$$$$$$$$$$$$
To continue Two-dimensional analysis using the command line.
Tuesday, April 14, 2009
% Two primal liftings starting from the Haar wavelet
% 14 april 09
%Example 2: . Two primal liftings starting from the Haar wavelet
% Get Haar filters.
[LoD,HiD,LoR,HiR] = wfilters('haar');
% Lift the Haar filters.
twoels(1) = struct('type','p','value',...
laurpoly([0.125 -0.125],0));
twoels(2) = struct('type','p','value',...
laurpoly([0.125 -0.125],1));
[LoDN,HiDN,LoRN,HiRN] = liftfilt(LoD,HiD,LoR,HiR,twoels);
% The biorthogonal wavelet bior1.3 is obtained up to
% an unsignificant sign.
[LoDB,HiDB,LoRB,HiRB] = wfilters('bior1.3');
samewavelet =isequal([LoDB,HiDB,LoRB,HiRB],[LoDN,-HiDN,LoRN,HiRN])
%samewavelet =
% 1
% Visualize the two times two pairs of scaling and wavelet
% functions.
bswfun(LoDN,HiDN,LoRN,HiRN,'plot');
%all correct
To continue ---lifting functions
(25 december 2008).