Question

Recall that if A is an m × n matrix and B is a p ×...

Recall that if A is an m × n matrix and B is a p × q matrix, then the product C = AB is defined if and only if n = p, in which case C is an m × q matrix. (a) Write a function M-file that takes as input two matrices A and B, and as output produces the product by columns of the two matrix. For instance, if A is 3 × 4 and B is 4 × 5, the product is given by the matrix C = [A*B(:,1), A*B(:,2), A*B(:,3), A*B(:,4), A*B(:,5)] The function file should work for any dimension of A and B and it should perform a check to see if the dimensions match (Hint: use a for loop to define each column of C). Call the file columnproduct.m. Test your function on a random 3×5 matrix A and a random 5×2 matrix B . Compare the output with A*B. Repeat with 4 × 6 and 6 × 2 matrices and with 4 × 6 and 2 × 6 matrices. Use the command rand to generate the random matrices for testing. Include in your lab report the function M-file and the output obtained by running it. (b) Write a function M-file that takes as input two matrices A and B, and as output produces the product by rows of the two matrices. For instance, if A is 3 × 4 and B is 4 × 5, the product AB is given by the matrix C = [A(1,:)*B; A(2,:)*B; A(3,:)*B] The function file should work for any dimension of A and B and it should perform a check to see if the dimensions match (Hint: use a for loop to define each row of C). Call the file rowproduct.m. Test your function on a random 3×5 matrix A and a random 5×2 matrix B . Compare the output with A*B. Repeat with 4 × 6 and 6 × 2 matrices and with 4 × 6 and 2 × 6 matrices. Use the command rand to generate the random matrices for testing. Include in your lab report the function M-file and the output obtained by running it.

Homework Answers

Answer #1

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
n×n-matrix M is symmetric if M = M^t. Matrix M is anti-symmetric if M^t = -M....
n×n-matrix M is symmetric if M = M^t. Matrix M is anti-symmetric if M^t = -M. 1. Show that the diagonal of an anti-symmetric matrix are zero 2. suppose that A,B are symmetric n × n-matrices. Prove that AB is symmetric if AB = BA. 3. Let A be any n×n-matrix. Prove that A+A^t is symmetric and A - A^t antisymmetric. 4. Prove that every n × n-matrix can be written as the sum of a symmetric and anti-symmetric matrix.
Creating a 6x8 matrix with rank 2 In general, rank(AB) <= min(rank(A), rank(B)). If A and...
Creating a 6x8 matrix with rank 2 In general, rank(AB) <= min(rank(A), rank(B)). If A and B are random matrices, the relation should be an equality. Try to create a 6x8 matrix with rank 2 by modifying the above procedure. (hint: mx2 times 2xn is mxn). Verify the matrix is rank 2 with the rank command
2. Write the output matrix “v” t = [2:4]; k = [1:3]; v = t.*k –...
2. Write the output matrix “v” t = [2:4]; k = [1:3]; v = t.*k – k.^2 4. Given: D = [1 2 3 4 5 6 7 8 9] (3x3) . Which command will extract the submatrix [1 2 3 4 5 6] (2x3) ? a. D[1:2,1:3] b. D(1,2 ;1,3) c. [D(1:2),D(1:3)] d. D(1:2,1:3) 14. What will be the dimension of matrix B? B=[ones(3) zeros(3) rand(3); 2*eye(9)] 18. Find the value of “C” A=1:2:10; B=linspace(1,5,5); C = length(A)*B(2)+A(5)*B(3); 19....
8. Consider a 4 × 2 matrix A and a 2 × 5 matrix B ....
8. Consider a 4 × 2 matrix A and a 2 × 5 matrix B . (a) What are the possible dimensions of the null space of AB? Justify your answer. (b) What are the possible dimensions of the range of AB Justify your answer. (c) Can the linear transformation define by A be one to one? Justify your answer. (d) Can the linear transformation define by B be onto? Justify your answer.
By Using Matlab Matcal (A, B) returns matrix A and B products, while printing the matrix...
By Using Matlab Matcal (A, B) returns matrix A and B products, while printing the matrix computation formula in outmat. txt file as follows. (The sizes of A and B are very variable. In other words, it shall be possible to perform operation for matrix operation of 2 x 2 size, and it shall also be possible to calculate and output for 100 X 100 matrix models. ) >> A = [1 23;4 56 ; 79] >> B = [0...
a).For the reduction of matrix determine the elementary matrices corresponding to each operation. M= 1 0...
a).For the reduction of matrix determine the elementary matrices corresponding to each operation. M= 1 0 2 1 5    1 1 5 2 7 1 2 8 4 12 b). Calculate the product P of these elementary matrices and verify that PM is the end result.
Matlab Queatoin: The test suite generates a random M x N matrix with a random number...
Matlab Queatoin: The test suite generates a random M x N matrix with a random number of rows and columns that is assigned to the variable A . The element values of the matrix are random double precision numbers that fall in the range from -10 to 10. The matrix has between 5 and 10 rows and between 5 and 10 columns. Assuming A is defined in the workspace, write a script with commands to perform the operations described below...
Step 1: Get OperationsBetween.java Compiling Download the OperationsBetween.java file, and open it in jGrasp (or a...
Step 1: Get OperationsBetween.java Compiling Download the OperationsBetween.java file, and open it in jGrasp (or a text editor of your choice). This program takes two command-line arguments representing the minimum and maximum number in a numeric range. Currently, the code does not compile. As a first step, you need to get this code to compile. To this end, you'll need to implement the following: Instance variables Constructor A “stub” for the sum method, which will allow the call to sum...
Perform the following matrix multiplications A = [2   5   6]       [-3 0   1] B =...
Perform the following matrix multiplications A = [2   5   6]       [-3 0   1] B = [ 1]        [ 3]        [-4] C = [-2   10   1] 6a. Find AB 6b. Find BC 6c. Find AC
MATLAB: Do the following with the provided .m file (a) In the .m file, we have...
MATLAB: Do the following with the provided .m file (a) In the .m file, we have provided three questions. Make sure to answer them. (b) Now on the MATLAB prompt, let us create any two 3 × 3 matrices and you can do the following: X=magic(3); Y=magic(3); X*Y matrixMultiplication3by3(X,Y) (c) Now write a new function in MATLAB called matrixMultiplication that can multiply any two n × n matrix. You can safely assume that we will not test your program with...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT