Manual Matlab

Páginas: 7 (1730 palabras) Publicado: 15 de diciembre de 2012
An Introduction to Statistics in Matlab
This guide is derived from the help files within Matlab. It identifies important concepts when working with Matlab as well as statistical tools that one might commonly use. It is not intended to be all-inclusive or explain all functions in great detail, but to serve as a quick reference when working with statistics in Matlab. For more information regardingthe concepts addressed in this guide or for Matlab operations that this guide omits, please refer to the Matlab help files, accessed through the menus within Matlab.

Table of Contents
1. An Introduction to Matrices and Arithmetic Operators a. Matrices b. Operators Basic Statistical Commands Hypothesis Testing a. Z-test b. T-test c. Two-sample t-test d. ANOVA Bootstrap Plotting with MatlabRegression and Curve-fitting a. Command-based Regression i. Setting up the Design Matrix by Hand ii. Using polyfit b. Graphical-based Regression c. Curve fitting tool Working with Probability Distributions a. CDF b. Parameter Estimation c. Quantiles d. Loglikelihood e. PDF f. Random number generation pg. 2 pg. 2 pg. 4 pg. 7 pg. pg. pg. pg. pg. 9 9 10 10 11

2. 3.

4. 5. 6.

pg. 13 pg. 14 pg. pg.pg. pg. pg. pg. pg. pg. pg. pg. pg. pg. pg. 16 16 16 17 18 19 22 22 23 23 24 25 25

7.

1

An Introduction to Matrices and Arithmetic Operators
Matrices
In Matlab, matrix operations are the basis for all calculations. A matrix is a two-dimensional array of real or complex numbers. A column vector is an m-by-1 matrix, created by the statement: c = [3;1;4];

A row vector is a 1-by-nmatrix, created by the statement: r = [3 1 4];

A scalar is a 1-by-1 matrix, created by the statement: s = 7;

To create a m-by-n matrix, you may string together row vectors, separated by a semicolon: m = [1 4 7 10; 2 5 8 11; 3 6 9 12];

Note that the use of the semicolon at the end of each line prevents the answer from being immediately returned by Matlab. To immediately view the output, simplyleave off the semicolon.

The dimensions of a matrix are displayed for each matrix (excluding vectors) in the workspace window. Alternatively, one can use the following command: a = size(A);

2

To obtain the transpose of a matrix, use "’". g = [4 3 1]; h = g’

For example,

(which returns

h = 4 3 1)

The identity matrix may be obtained using the command "eye". i = eye(3,2) (whichreturns i = 1 0 0 i = 1 0 0 1 0) 0 1)

i = eye(2)

(which returns

To get the inverse of a matrix, use "inv". A = [1 1 1; 1 2 3; 1 3 6]; X = inv(A)

(which returns

X =

3 -3 1

-3 5 -2

1 -2 1)

To get the determinant of a matrix, use "det". d = det(A) (which returns d = 1)

This may be necessary when performing certain calculations, as the command may simply return NaN whenyou wished to disregard these values.

To get a matrix of ones [or zeros], use the following commands: a = ones(2,3); b = zeros(2,3); which will return 2-by-3 matrices of ones [or zeros respectively].

3

For simplicity (and the fact that one will need matrices of ones or zeros that are the same size as other matrices) use the command: c = zeros(size(C)); to get a matrix of zeros that has thesame dimensions as C.

Missing values may be indicated with the value NaN. To remove these values from your named variable, use the following command: x = x(˜isnan(x));

Operators
To add and subtract matrices, they must be of the same size (same number of rows and columns). Then, simply use "+" or "-". For example, A B r s = = = = [2 3; 4 5]; [2 1; 5 8]; [3 1 4]; 7;

C = A + B

(whichreturns C = [4 9

4 13])

To do matrix multiplication, simply use "*". r as defined above, w = r * c w = c * r (which returns w = 26) (which returns w =[9 3 12 3 1 4 12 4 16])

For example, using c and

Similarly, with scalars, w = r * s (which returns w = [21 7 28]) 4

To raise a matrix to a power (using matrix multiplication), simply use "ˆ". C = Aˆ2 (from above) (which returns C =...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Manual De Matlab
  • manual matlab
  • Manual de matlab
  • Manual de matlab
  • Manual matlab
  • Manual matlab
  • Manual matlab
  • Manual Matlab

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS