Preview

Matrices in Matlab

Good Essays
Open Document
Open Document
6867 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Matrices in Matlab
Section 2.2

Matrices in Matlab 75

2.2 Matrices in Matlab
You can think of a matrix as being made up of 1 or more row vectors of equal length. Equivalently, you can think of a matrix of being made up of 1 or more column vectors of equal length. Consider, for example, the matrix   1 2 3 0 A =  5 −1 0 0  . 3 −2 5 0 One could say that the matrix A is made up of 3 rows of length 4. Equivalently, one could say that matrix A is made up of 4 columns of length 3. In either model, we have 3 rows and 4 columns. We will say that the dimensions of the matrix are 3-by-4, sometimes written 3 × 4. We already know how to enter a matrix in Matlab: delimit each item in a row with a space or comma, and start a new row by ending a row with a semicolon. >> A=[1 2 3 0;5 -1 0 0;3 -2 5 0] A = 1 2 3 0 5 -1 0 0 3 -2 5 0 We can use Matlab’s size command to determine the dimensions of any matrix. >> size(A) ans = 3 4 That’s 3 rows and 4 columns!

Indexing
Indexing matrices in Matlab is similar to the indexing we saw with vectors. The difference is that there is another dimension 2. To access the element in row 2 column 3 of matrix A, enter this command.

1 2

Copyrighted material. See: http://msenux.redwoods.edu/Math4Textbook/ We’ll see later that we can have more than two dimensions.

76 Chapter 2

Vectors and Matrices in Matlab

>> A(2,3) ans = 0 This is indeed the element in row 2, column 3 of matrix A. You can access an entire row with Matlab’s colon operator. The command A(2,:) essentially means “row 2 every column” of matrix A. >> A(2,:) ans = 5 -1

0

0

Note that this is the second row of matrix A. Similarly, you can access any column of matrix A. The notation A(:,2) is pronounced “every row column 2” of matrix A. >> A(:,2) ans = 2 -1 -2 Note that this is the second column of matrix A. You can also extract a submatrix from the matrix A with indexing. Suppose, for example, that you would like to extract a submatrix using rows 1 and 3 and columns 2 and 4. >>

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Pt1420 Unit 6 Lab Report

    • 288 Words
    • 2 Pages

    Step 10 : Calculate the key as number of columns of all the matrices including 3…

    • 288 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    The matrix elements are complex numbers that correspond to the attenuation and phase shift that the wireless communication channel introduces to the signal reaching the receiver with delay τ.…

    • 674 Words
    • 3 Pages
    Good Essays
  • Good Essays

    metcs520 W4 Assignment

    • 637 Words
    • 8 Pages

    of the first red block in the bottom row. The next two values are the…

    • 637 Words
    • 8 Pages
    Good Essays
  • Powerful Essays

    Ap Calculus

    • 2722 Words
    • 11 Pages

    | A cell reference that refers to cells by their fixed position in a worksheet; an absolute cell reference remains the same when the formula is copied.…

    • 2722 Words
    • 11 Pages
    Powerful Essays
  • Good Essays

    Chapter 8 Quiz

    • 469 Words
    • 2 Pages

    2. What is the term used for the number inside the bracket that specifies the number of values that an array can hold? (Points : 7)…

    • 469 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Bus Midterm

    • 1408 Words
    • 6 Pages

    For each of the five dimensions, give an example of how the differences you have…

    • 1408 Words
    • 6 Pages
    Good Essays
  • Good Essays

    This examination is designed to test your ability to calculate efficiently with the aid of MATLAB as…

    • 1357 Words
    • 17 Pages
    Good Essays
  • Best Essays

    Ross, M. (2009, May 29). The 10 Essential Rules of Dimensional Modeling. Retrieved from http://www.informationweek.com/news/software/bi/showArticle.jhtml?articleID=217700810&pgno=1&queryText=&isPrev=…

    • 1512 Words
    • 7 Pages
    Best Essays
  • Satisfactory Essays

    The n in this expression is the index. When it is a variable like this, it is common to say the nth root. If the index were 4, it would be the fourth root. If there is no index shown, then it is understood that the index is 2, as in a standard square root.…

    • 364 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Statistics Using Excel

    • 689 Words
    • 3 Pages

    addresses and not the data in the cells, which may change from one iteration of the test to…

    • 689 Words
    • 3 Pages
    Good Essays
  • Good Essays

    The 4th Dimension

    • 913 Words
    • 4 Pages

    Let’s start with 0 –dimensions. When we classify an object’s dimensions we classify it according to the number of degrees of freedom it has. Therefore a 0-dimensional object would have zero degrees of freedom and would be represented as a point. With 0-dimensions you do not need any information to locate a point within that dimension. This is true because any 0-dimensional object has no length width or height. Now think about taking that point and simply sweeping it to the left like you are drawing a line with the point. By sweeping the point in a line you have just taken a zero dimensional point and created a 1-dimensional line. All of 1-dimensional space is a line. Within a line there is only one degree of freedom, or one direction in which the line is capable of moving. It may seem like a line should be classified as a 2-dimensional object because it can move left and right but really it is based on how many different directions the line travels, which is one left and right. Now think about a line as your street. Your specific house would only be one point on that street and in order to find it you would only need to tell one number in order for it to be found.…

    • 913 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    3. This method of multiplication can be expanded to matrices other that 2x2. However, due to space constraints, on a test, usually you will only see a 2 x2 matrix or smaller.…

    • 320 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    where A is the matrix of coefficients of the system (the main matrix), A = [aik]mn, b is the…

    • 3080 Words
    • 13 Pages
    Good Essays
  • Good Essays

    “The sum of the numbers in any row is equal to 2 to the nth power or 2^n when n represents the number of the row.” For example:…

    • 671 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Questions on Mathematics

    • 1037 Words
    • 21 Pages

    The equation f(x) : 0 has another root B in the interval [-1, 0]. Starting with this…

    • 1037 Words
    • 21 Pages
    Satisfactory Essays

Related Topics