Expressions: + (addition) - (substrction) * (multiplication) / (division) \ (left division of matrix) ^ (power) ‘ (complex conjugate transpose) help elfun % list all elementary math functions helpspecfun % list specific math functions help elmat % list matrix functions v = [1, 3, 5] % define vector v and print output e=[0.1 0.2 0.4 0.6 0.8]; % define vector e but no print out x = 0: 2: 8; %Generate vectors x giving [ 0 2 4 6 8] x = linspace(a,b,n) % returns a vector with n elements in the interval [a,b] x = logspace(a,b,n) % returns a vector with n elements in the interval[10a,10b] A = [1 23; 4 5 6; 7 8 9] % generates a matrix by input If an ASCII-file A.dat is created by an editor and has in it: 1 4 5 4 2 9 load A.dat A % load the file into matrix A save B.dat A % saves the matrix Ainto file B.dat A, B, C, D are matrices A=eye (3) % generate a 3x3 Identity Matrix B=zeros(2,4) % generate a 2x4 Zero matrix C=ones(3,2) % generate a 3x2 matrix with one assigned to all elements A’A(1,3) V=A(1:4,2) V=A(:,3) V=A(:,end) D=[A C] D=[A;C-2] D=[A C; A-2 C] D(:,2) = [] sum(A) diag(A) det(A) inv(A) eig(A) poly(A) A*B A.*B A./B A.\B A.^n % gives the Transpose of matrix A % gives the (1,3)element of matrix A % takes the elements (1,2),(2,2),(3,2),(4,2) from matrix A to form vector V % takes the column 3 of matrix A to form vector V % takes the last column of matrix A to form vector V %concatenate matrix A & C (append the columns of C to the columns of A) % subtract 2 from each element of C and append it as the bottom rows of A % concatenate to form new matrix % delete the secondcolumn of matrix D % gives the sum of each column of matrix A % gives the diagonal of matrix A % return the determinant of matrix A % return the inverse of matrix A % return the eigen values of matrixA % returns the coefficients of the characteristic polynomial det(A-λI) % multiply matrix A by matrix B % (i,j) element of the product matrix is A(i,j)*B(i,j) % (i,j) element of the result matrix is...
Leer documento completo
Regístrate para leer el documento completo.