Question 2. Block Matrices and Special Matrices With MATLAB it is easy to form new matrices from those that are already in the workspace and to create matrices of special types. (a) You can create block matrices by putting two matrices side by side (if they have the same number of rows), or one on top of the other (if they have the same number of columns). Use the matrices A,B,C,D,X created in Question 1 to Ynake the following block matrices (the semicolon means that the matrices are stacked one on top of the other). Before typing the MATLAB commands, insert a comment line that lists which of the Math 250C Matlab \# 14 matrix combinations in this list fit together. Then use MNTLAB (you will get error mesagges when the matrix sizes are not compatible). [[A]?X?[BC][C?D]?[C;B]?[B;D]? (b) Type each of the following commands that generate special matrices. eye(4) zeros(3) zeros (3,5) ones (2,3) diag ([4?5?6?7?)
Question 3. Matrix Addition and Matrix-Vector Multiplication Generate vectors u and v and matrices A and B by typing u=fix(10?rand(3,1)),A=fix(10?rand(2,3)),?v=fix(10?rand(3,1)),B=fix(10?rand(2,3))? These matrices have entries randomly selected from the numbers 0,1,…,9. (a) To obtain a linear combination sA+tB of the matrices A and B (where s and t are real numbers) using MATLAB, you must type s?A+t?B. This is only defined when A and B are the same size. The transpose AT of A is obtained by typing A?. Calculate the following using MATLAB. A+B,B+A,6B,2(3B),6A+15B,3(2A+5B);3A1?(3AT)T Insert comments in your diary file that explain the properties of matrix addition and scalar multiplication that these calculations illustrate. (See Theorems 1.1 and 1.2 on pages 6 and 7 of the text.) (b) To obtain the matrix-vector product Au using MATLAB, you must type A*u (remember that a vector is just a matrix with one column). Calculate the following using MATLAB. Au+Av,A(u+v),(A+B)u,Au+Bu,A(3u),3A(u)
Insert comments in your diary file that explain the properties of the matrix-vector product that these calculations illustrate. (See Theorem 1.3 on page 24 of the text.) Question 4. Gaussian Elimination and Reduced Row-Echelon Form Now that you know how to do matrix calculations with MATLAB, you can easily carry out the steps in Gaussian eliminalion. Before starting work on this question, type rrefmovie at the MatLAB prompt. If you get an error message ??? Undefined function or variable rrefmovie, click on Set Path on the toolbar. Insert the name of the directory where you have copied the Tcode rrefmovie.m, and save the result (you will need to do this in future labs also). You will see a step-by-step example of the row operations that transform a matrix A into its reduced row echelon form R=rref(A). In this demonstration, each pivot is chosen to be the largest in its column (for numerical stability), so extra row interchanges are used. Since rref (A) is uniquely determined by A, this does not affect the final answer. (Do not include this part in your lab write-up.) (a) Generate a 3×4 matrix A with random integer entries by the command A=fix(10?rand(3,4)) To transform A into R=rref(A), start with R=A. Normalize the first row of R to get R(1,1)=1 : R=A;R(1,i)=R(1,i)/R(1,1) (note the use of the colon to operate on whole rows of the matrix). If your random matrix happens to have A(1,1)=0, then interchange rows to get a nonzero entry in the (1,1) position before doing the calculation above. Now subtract a multiple of the first row of R from the second row to make R(2,1)=0 : R(2,i)=R(2,i)?R(2,1)?R(1,i) Repeat this procedure to make R(3,1)=0 : R(3,;)=R(3,i)=R(3,1)?R(1,i) (you can minimize typing by using the up-arrow key and editing the command line). The first column of your matrix R should now be the same as the first column of rref(A). (b) Operate on R by the same method as in (a) to obtain the second column of rref (A). First normalize row 2 of R, then subtract multiples of fow 2 from rows 1 and 3 to put zeros in the (1,2) and (3,2) positions (you can minimize typing by using the up-arrow key and editing the commands used in part (a)). Be sure to refer to the entries in your matrix symbolically as was done in part (a); don't type explicit decimal numbers in the MATLAB commands.
row 2 of R, then subtract multiples of row 2 from rows 1 and 3 to put zeros in the (1,2) and (3,2) positions (you can minimize typing by using the up-arrow key and editing the commands used in part (a)). Be sure to refer to the entries in your matrix symbolically as was done in part (a); don't type explicit decimal numbers in the MATLAB commands. (c) Operate on R by the same method as in (b) to obtain the third column of rref (A). First normalize row 3 of R, then subtract multiples of row 3 from rows 1 and 2 to put zeros in the (1,3) and (2,3) positions. (d) Your matrix R should now be transformed into rref (A) (since A is a random 3×4 matrix, rref(A) is "(almost)"sure to have rank 3 ). Check your answer by MATLAB with the command rref (A). If the MatLAB answer is not the same as the current value of your R, go back and redo your calculations. Question 5. Leontief Input-Output Model Read pages 56?59 of Section 1.5 in the text and study Practice Problem 1 on page 59 and its solution on page 65. (a) Use MATLAB to create the input-output matrix C for the economy described in Exercise 22 on page 63 , as follows: Create 3×1 column vectors à, m, and s that correspond to the agricultural, manufacturing, and services sectors, respectively. Then set C=[a,m,s]. (b) Use the gross production vector x in part (a) of Exercise 22 and the matrix C to calculate the net production vector. Describe in words the net production (in millions of $ ) of each sector of the economy.
(c) Let d be the demand vector described in part (b) of Exercise 22 . (i) Write (in symbolic form) the inhomogeneous equation that the gross production vector x must satisfy in order to satisfy demand d. (See the boxed statement at the top of page 59 of the text.) (ii) Use the MatLaB rref command on a suitable augmented matrix to solve the equation in (i) for x. Desçibe in words the gross production (in millions of \$) of each sector of the economy that are needed to satisfy the given demand d.