Books in black and white
 Books Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

# 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
Previous << 1 .. 92 93 94 95 96 97 < 98 > 99 100 101 102 103 104 .. 112 >> Next

erf: error function. Y=erf(X) is the error function for each element of X. X must be real. The error function is defined as
erf(x)=2/sqrt(^ ) J0Xexp(-t2)dt.
erfinv: inverse error function. X = erfinv(Y) is the inverse error function for each element of X. The inverse error functions satisfies
y=erf(x), for -1 <= y < 1 and -to < x < to.
Note that all the functions mentioned above can be conveniently used for calculations. This may be one of the most convenient features of the MATLAB language.
A.2.4. Methods for Generating Vectors and Matrices
The colon operator in MATLAB is one of the most convenient tools for constructing vectors and/or matrices. For instance, with the following commands, one can easily obtain a function data table:
>x=[0.0 : 0.2 : 3.0]’; (obtaining the first column in the ans table) >y=-exp(x).* sin(x); (obtaining the second column in the ans
table)
>[x y]ans=
0 0 0.2000 -0.2427
0.4000 -0.5809
0.6000 -1.0288 0.8000 -1.5965
1.0000 -2.2874
1.2000 -3.0945
1.4000 -3.9962
1.6000 -4.9509
appendix
279
1.8000 -5.8914
2.0000 -6.7188
2.2000 -7.2967
2.4000 -7.4457
2.6000 -6.9406
2.8000 -5.5088
3.0000 -2.8345
One can also use the linspace function to produce linearly spaced vectors and the logspace function to generate logarithmically spaced vectors. For instance, linspace(x1, x2, N) will gives N linearly equally spaced points between x1 and x2.
If we key in the following statement
>linspace(.3,5.2,14)
the results obtained will be as follows:
ans=
Columns 1 through 7
0.3000 0.6769 1.0538 1.4308 1.8077 2.1846 2.5615
Columns 8 through 14
2.9385 3.3154 3.6923 4.0692 4.4462 4.8231 5.2000
MATLAB also provides functions to construct some special matrices. These include
diag: diagonal matrices and diagonals of a matrix. diag(V,K) where V is a vector with N components and K is an integer, the functions returns a square matrix of order N+abs(K) with the elements of V on the Kth diagonal. K=0 is the main diagonal, K > 0 is above the main diagonal; and K < 0 is below the main diagonal. If X is a matrix, diag(X) returns the main diagonal of X. Thus, diag(diag(X)) returns a diagonal matrix.
Hadamard: Hadamard matrix. hadamard(N) is a Hadamard matrix of order N, that is, a matrix, say, H, with elements 1 or -1 such that h'*h=N*In (where IN denotes the identity matrix of order N). A N-by-N (N x N) Hadamard matrix with N > 2 exists only if N is divisible by 4, that is, rem(N,4)=0.
280
appendix
ones: ones array. ones(N) returns a matrix of order N with all the elements equals to one. ones(size(A)) gives a matrix of the same size as A with all the elements equal to one. rand: uniformly distributed random numbers. rand(N) is an N-by-N matrix of random numbers that are uniformly distributed in the interval (0.0,1.0). rand with no argument returns a scalar, while rand(size(A)) is a matrix of the same size as A. randn: normally distributed random numbers. randn(N) is an N-by-N matrix of random numbers that follow the normal distribution with mean zero and unity variance. randn(size(A)) returns a matrix of the same size as A. eye: identity matrix. eye(N) returns an identity matrix of order N. eye(size(A)) is an identity matrix having the same size as A.
Thus, to produce a random matrix of order 3 x 5, one can simply key in the following statement:
>rand(3,5)
The results are as follows:
ans=
0.9501 0.4860 0.4565 0.4447 0.9218
0.2311 0.8913 0.0185 0.6154 0.7382
0.6068 0.7621 0.8214 0.7919 0.1763
With these functions, we can easily construct data matrices of any size.
A.2.5. Matrix Subscript System
In order to indicate the position of an element in a matrix, subscripts are always used in mathematics. In principle, MATLAB follows the same rules as those of mathematics. There is no difference between MATLAB and other advanced computer languages. The only difference in MATLAB is that it is possible for MATLAB to use a vector subscript to define submatrix, through which MATLAB makes the matrix operation very convenient. For instance, if A is a matrix of order 10 x 10, the statement
>A(1:5,3)
can be used to construct a column vector of order 5 x 1, which consists of the first five elements in the third column in matrix A. Again, if we key in the statement
>X=A(1:5,7:10);
appendix
281
Figure A.11. Generation of a 5 x 4 submatrix using the command X=A(1:5,7:10) to specify the 20 elements (located in an upper right region with label X) within the 10 x 10 matrix A.
we can obtain a new matrix of X of order 5 x 4, which contains the elements in the last four columns and in the first five rows in matrix A as shown in Figure A.11, It should be noted that in this expression, if we use only a colon without specifying the starting and ending positions, the command embraces all the rows and/or all the columns of the matrix identified. For example, the statement >A(:,3)
gives the third column in matrix A, while the command
>A(1:5,:)
gives the first five rows in matrix A.
The subscript expression of a matrix can be used in input statements, which makes the matrix operation in MATLAB very convenient. For instance, the following commands can be employed to construct two matrices, B and a:
Previous << 1 .. 92 93 94 95 96 97 < 98 > 99 100 101 102 103 104 .. 112 >> Next