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.
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
Write a MATLAB function that outputs number of values in a matrix that’s greater than a...
Write a MATLAB function that outputs number of values in a matrix that’s greater than a compare value. The function must able to take in an arbitrary size matrix. Name your script/program as “Quiz 2”. Examples : Matrix = [1 2 3; 4 5 6]           Compare_Value = 2 Output = 4 Matrix = [1 2 3 1; 4 5 6 8]           Compare_Value = 2 Output = 5
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its...
MATLAB: Write a function called matrix_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice that the output matrix will have all even elements. For example, the call B = matrix_problem([1 4; 5 2; 3 1], will make B equal to [2 4; 10 2; 6 2]. The function should work...
1- Create a new script that is called HW9.m and save it. The script will do...
1- Create a new script that is called HW9.m and save it. The script will do the following. Test your code for each of the cases and upload your script as a .m file. [15 points] a. Create a random integer numbers that goes from 0 to 5 and assign it to a variable y using rand and round commands. Hint: Note that rand function only creates random number between 0 and 1. You need to scale the values to...