MATLAB Matrices
MATLAB Matrices
ways to create a matrix
1. type in matrix
[1-3,7;2,4,8]
1-3 7
2 4 8
2. zeros(N)
NxN matrix containing all zeros
3. rand(N)
NxN matrix of random numbers
4. randn(N)
NxN matrix of random numbers (positive and negative)
5. ones(N)
NxN matrix containig all ones
6. size(n)
will create a 1x2 matrix and tell the size of matrix “n”
7. diag(A)
lists the elements in the diagonal of matrix “A”
diag(A,k) lists the elements of the k-th diagonal
0.9047 0.4940 0.5007 0.4644
0.5045 0.2661 0.3841 0.9410
0.5163 0.0907 0.2771 0.0501
0.3190 0.9478 0.9138 0.7615
0.9866 0.0737 0.5297 0.7702
diag(a,2) 0.4940
diag(a) 0.1665
8. flipud(A)
flips the columns in matrix “A”
A =
0.6793 0.5194
0.9347 0.8310
0.3835 0.0346
» flipud(A)
ans =
0.3835 0.0346
0.9347 0.8310
0.6793 0.5194
9. fliplr(A)
flips rows in matrix “A”
A =
0.6793 0.5194
0.9347 0.8310
0.3835 0.0346
fliplr(A)
0.6793 0.2190
0.9347 0.0470
0.3835 0.6789
10. reshape(A,m,n)
rearranges matrix A to an mxn matrix
A =
2 3 13
11 10 8
7 6 12
14 15 1
reshape(A,8,2)
3
10
6
15
13
8
12
1
11. rot90
rotates matrix 90 degrees
rot90(N) rotates “N” ccw 90 degrees
rot90(N,k) rotates “N” ccw by k*90 degrees - k must be an integer
12. hankel
a matrix that is symmetric about and constant across the anti-diagonals
hankel(c) first column is c and ele below first anti-diag are zero
hankel(2:5)
ans =
3 4 5
4 5 0
5 0 0
0 0 0
13. hankel(c, r) first column is c and last row is r, if last of c and first of are differ, c wins
r=7:10;
hankel(c,r)
Column wins anti-diagonal conflict.
ans =
2 3 8
3 8 9
8 9 10
14. magic(N)
NxN matrix - a magic square, all rows and columns add to the same number
15. toeplitz
generates a toeplitz matrix given just the row or column description
toeplitz(c) symmetric matrix formed from vector “c”
[1:1:5];
toeplitz(c)
2 3 4 5
1 2 3 4
2 1 2 3
3 2 1 2
4 3 2 1
16. toeplitz(c,r)non-symm where c is first column and r is first row
[1.5:1:5.5];
[1:1:5];
toeplitz(c,r)
Column wins diagonal conflict.
2.5000 3.5000 4.5000 5.5000
1.0000 2.5000 3.5000 4.5000
2.0000 1.0000 2.5000 3.5000
3.0000 2.0000 1.0000 2.5000
4.0000 3.0000 2.0000 1.0000
17. compan(p)
companion matrix whose first row is -p(2:n)/p(1) -
[10 30 -70 60] - represents the polynomial 10x^3 + 30x^2 - 70x + 60
compan(p) (see also :”characteristic polynomial”)
7 -6
0 0
1 0
18. hadamard(N)
a Hadamard matrix of order N - a hadamard matrix is a matrix with 1’s and -1’s whose columns are orthogonal
hadamard(4)
1 1 1
-1 1 -1
1 -1 -1
-1 -1 1
19. meshgrid(x,y)
takes a vector and makes it an array (list of number) that can be plotted on a 3-D plot.
To eval and plot the function z=x^2+y^2
=meshgrid(-2:.2:2);
mesh(z)
20. forloop
programming tool which repeats an algorithm n number of times.
for i:n;
forj:n
=i^2+j^2
end
end
21. pascal(N)
PASCAL(N) is the Pascal matrix of order N: a symmetric positive
definite matrix with integer entries, made up from Pascal's
triangle. Its inverse has integer entries.
PASCAL(N,1) is the lower triangular Cholesky factor (up to signs
of columns) of the Pascal matrix. It is involutary (is its own
inverse).
PASCAL(N,2) is a transposed and permuted version of PASCAL(N,1)
which is a cube root of the identity.(from help pascal on MATLAB)
22. vander(N)
Vandermonde matrix.
VANDER(N) returns the Vandermonde matrix whose second to
last column is N. The j-th column of a Vandermonde
matrix is given by A(:,j) = N^(n-j).
For other matrices see hilb, invhilb, rosser,wilkinson
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- matrices calculator solver
- matrices calculator with steps
- solving systems using matrices calculator
- solve matrices calculator
- solve systems with matrices calculator
- equations into matrices calculator
- system of equations matrices calculator
- using matrices to solve systems
- multiply matrices calculator
- matrices and determinants calculator
- matrices and systems of equations
- determinants of matrices calculator