Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The product y = A x of an m n matrix A times a vector x = ( x 1 , x 2 , dots,

The product y=Ax of an mn matrix A times a vector x=(x1,x2,dots,xn)T can be
computed row-wise as
y=[A(1,:)**x;A(2,:)**x;dots;A(m,:)**x];
that is
y(1)=A(1,:)**x
y(2)=A(2,:)**x
cdots
y(m)=A(m,:)**x
Write a function 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 25 matrix A and a random 51 vector x. Compare the
output with A**x.
Repeat with a 54 matrix and a 41 vector and with a 54 matrix and a 14 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.
image text in transcribed

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

Mass And Heat Transfer Analysis Of Mass Contactors And Heat Exchangers

Authors: T. W. Fraser Russell, Anne Skaja Robinson, Norman J. Wagner

1st Edition

0521886708, 9780521886703

More Books

Students also viewed these Chemical Engineering questions

Question

What is a verb?

Answered: 1 week ago