Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Chemometrics from basick to wavelet transform - Chau F.T

Chau F.T Chemometrics from basick to wavelet transform - Wiley publishing , 2004. - 333 p.
ISBN 0-471-20242-8
Download (direct link): chemometricsfrombasics2004.pdf
Previous << 1 .. 94 95 96 97 98 99 < 100 > 101 102 103 104 105 106 .. 112 >> Next

appendix
285
Please note that if an N-dimensional array X is passed as the argument, all the functions listed above operate on the first nonsingleton dimension of X.
conv: convolution and polynomial multiplication. C = conv(A, B) convolves vectors A and B. The resulting vector is length LENGTH(A) + LENGTH(B) 1. If A and B are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials.
corrcoef: correlation coefficients. corrcoef(X) is a matrix of correlation coefficients formed from array X whose each row is an observation, and each column is a variable. corrcoef(X,Y), where X and Y are column vectors, is the same as corrcoef([X Y]) .
Consider the following examples. First, let a matrix B be defined and the outputs of a few functions mentioned above be shown as
>B= [1 4 7 10 5; 2 5 8 11 4; 3 6 9 12 6; 2 5 7 3 2]
>B=
1
2
3
2
4
5
6 5
7 10
8 11
9 12
7 3
5 4
6 2
>max(B) ans =
3 6 9 12 6
>min(B) ans =
1 4 7 3 2
>mean(B) ans =
2.0000 5.0000 7.7500 9.0000 4.2500
>prod(B)
ans =
12 600 3528 3960 240
286
appendix
>sort(B) ans =
1
2
2
3
3 2
10 4
11 5
12 6
>corrcoef(B)
1.0000 1.0000 0.8528 0.2000 0.2390
1.0000 1.0000 0.8528 0.2000 0.2390
0.8528 0.8528 1.0000 0.6822 0.6625
0.2000 0.2000 0.6822 1.0000 0.9084
0.2390 0.2390 0.6625 0.9084 1.0000
The most attractive feature of the MATLAB language is that it provides very convenient functions for matrix operations. It makes some programs for processing chemical signals very easy and convenient to implement. Moreover, computations involving MATLAB script are usually very fast and efficient, significantly simplifying and facilitating chemometric programming in the MATLAB language.
A.2.6. Matrix Decomposition
Matrix decomposition is the core of chemometric techniques. Many algorithms used in chemometrics are based on matrix decomposition, such as principal-component analysis (PCA) and partial least squares (PLS). Some familiarity with the basic ideas of matrix decomposition will make it easier to follow the algorithms presented in this book.
A.2.6.1. Singular-Value Decomposition (SVD)
Singular-value decomposition is very important in chemometrics. In MATLAB, matrix decomposition can be performed simply by the following statement
>[U,S,V]=svd(A)
ans
in which U is a column orthogonal matrix or so-called scores, matrix V is a row orthogonal matrix or so-called loadings, and matrix S is a diagonal
appendix
287
matrix satisfying the following relation:
A=U*S*V
For example, assume that
>A=[1 4 7 10; 2 5 8 11; 369 12] Then, we have A=
1 4 7 10
2 5 8 11
3 6 9 12
Then, we can simply key in >[U,S,V]=svd(A)
The following results are obtained: U=
0.5045
0.5745
0.6445
0.7608
0.0571
0.6465
0.4082
0.8165
0.4082
25.4624
0
0
0
1.2907
0
0
0
0.0000
0.1409
0.3439
0.5470
0.7501
0.8247
0.4263
0.0278
0.3706
0.1605
0.1764
0.8342
0.4973
0.5237
0.8179
0.0647
0.2295
A.2.6.2. Eigenvalues and Eigenvectors (eig)
Suppose that A is a square matrix. If a vector x and a scalar a satisfy theequation Ax=ax, then x and a are respectively called the eigenvector and eigenvalue of matrix A. In MATLAB, eigenvalues of A can be obtained by the following statement:
>e=eig(A)
Here e is a vector containing all the eigenvalues of A. If one also requires the corresponding eigenvectors, then the statement
>[V,D]=eig(A)
288
appendix
will produce a diagonal matrix D of eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that A*V=V*D. In addition, E=eig(A,B) is a vector containing the generalized eigenvalues of square matrices A and B. The statement [V,D]=eig(A,B) produces a diagonal matrix D of generalized eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that A*V=B*V*D. For example, if
>[x,d]=eig(A*A) then, we have
x=
0.5279 -0.1462 -0.8247 0.1409
-0.8128 -0.1986 -0.4263 0.3439
0.0419 0.8356 -0.0278 0.5470
0.2430 -0.4909 0.3706 0.7501
-0.0000 0 0 0
0 0.0000 0 0
0 0 1.6658 0
0 0 0 648.3342
A.2.7. Graphic Functions
The MATLAB graphic functions are very powerful and extremely useful in generating scientific plots for data analysis, interpretation, and publication. These functions are very difficult to implement in most of the advanced computer languages without accessing other sophisticated graphic libraries. For instance, mesh plots and contour plots can be easily created in MATLAB. One simple statement can do the job. Here we give a very brief introduction on the graphics features of MATLAB.
We can begin by constructing a matrix of order 16 x 16 and then use this matrix data to show several powerful plotting functions in MATLAB. A small matrix is created first:
>A= [4 5 3 8
16 9 2
7 8 2 8
9 4 12 6]
A=
4 5 3 8
16 9 2
7 8 2 8
9 4 12 6
appendix
289
Figure A.12. A plot of the ninth column vector (contains 16 elements) of the matrix B-i.
Then, we enlarge the order of the matrix and key in the following statements:
Previous << 1 .. 94 95 96 97 98 99 < 100 > 101 102 103 104 105 106 .. 112 >> Next