Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB HELP PLS NEED THE CODE The product y=Ax of an mn matrix A times a vector x=(x1,x2,,xn)T can be computed row-wise as y=[A(1,:)x;A(2,:)x;;A(m,:)x]; that

MATLAB HELP PLS NEED THE CODE
image text in transcribed
image text in transcribed
The product y=Ax of an mn matrix A times a vector x=(x1,x2,,xn)T can be computed row-wise as y=[A(1,:)x;A(2,:)x;;A(m,:)x]; that is y(1)=y(2)=y(m)=A(1,:)xA(2,:)xA(m,:)x Write a funct Yon M-file that takes as input a matrix A and a vector x, and as output gives the product y=Ax by row, as defined above (Hint: use a for loop to define each entry of the vector y. Your M-file should perform a check on the dimensions of the input variables A and x and return a message if the dimensions do not match. Call the file myrowproduct.m. Note that this file will NOT be the same as the myproduct.m example. Test your function on a random 52 matrix A and a random 21 vector x. Compare the output with Ax. Repeat with a 43 matrix and a 31 vector and with a 43 matrix and a 13 vector. 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. 5. Recall that if A is an mn matrix and B is a pq matrix, then the product C=AB is defined if and only if n=p, in which case C is an mq 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 34 and B is 45, the product is given by the matrix C=[AB(::1);AB(:,2),AB(:,3),AB(:,4),AB(:,5)] THIS CONTENT IS PROTECTED AND MAY NOT BE SHAAED, UPLOADED, SOLD OR DISTRIEUTED 2021 v1 Copyright a School of Mathematical and Statiatical Sciences, Arizona State University 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 26 matrix A and a random 64 matrix B. Compare the output with AB. Repeat with 44 and 43 matrices and with 44 and 34 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 34 and B is 45, 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 26 matrix A and a random 64 matrix B. Compare the output with AB. Repeat with 44 and 43 matrices and with 44 and 34 matrices

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions