Exercises

Answer each question.

  1. Solve these problems in Matlab

    [3 0 1;-2 4 6; -3 1 5]x[1 -1 4; .5 0 3.2; 1.4 -1.1 3]

    A=[3 0 1;-2 4 6; -3 1 5]
    B=[1 -1 4; .5 0 3.2; 1.4 -1.1 3]
    C=A*B

    C = [4.4 -4.1 15 ; 8.4 -4.6 22.8; 4.5 -2.5 6.2]

  2. Solve these problems in Matlab

    [1 2 3 4;-4 -3 -2 -1;1 0 1 0 ; 4.1 2 4.1 2]x[1 0 0 -3;4 2 1.1 -.3;3 -9 3 2;1 2.1 3 4]

    A=[1 2 3 4;-4 -3 -2 -1;1 0 1 0 ; 4.1 2 4.1 2];
    B=[1 0 0 -3;4 2 1.1 -.3;3 -9 3 2;1 2.1 3 4];
    C=A*B

    C = [22 -14.6 23.2 18.4; -23 9.9 -12.3 4.9; 4 -9 3 -1; 26.4 -28.7 20.5 3.3]

  3. How you get the first, fourth, and 17th rows of a matrix named P?

    To get only the first, fourth, and 17th columns from a matrix named P, use this term: P([1,4,17],:), which can be read all columns of rows 1,4, and 17 of P.

  4. Use Matlab to create a subset of a matrix named S that includes only the values that are in odd rows and even columns of matrix named S?

    [r,c] = size(S);
    T = S([1:2:r],[2:2:c]

    Note: The syntax is matrixName( vectorOfRowNumbers, vectorOfColNumbers ).

  5. Assuming that you correctly entered the matrix SCRIBNER_DECIMAL_C as described in Example 6, what command would return the value for a log that was 21 inches in width and 10 feet long?

    Can you think of a way to get the correct result using variable named W that contains the width in inches and a variable named L that contains the length in feet?

    SCRIBNER_DECIMAL_C(16,4)

    The following command would work if the width in W is an integer from 6 to 30 and the length in L is an even integer from 6 to 16:

    SCRIBNER_DECIMAL_C(W-5,L/2+1)

    We will learn how to test for valid values in the programming unit of the course.