Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using MATLAB Instructions: For the following exercise, copy and paste into a text document the function M-files and the output obtained by running them. 4.

Using MATLAB

Instructions: For the following exercise, copy and paste into a text document the function M-files and the output obtained by running them.

image text in transcribed

4. The product y = Ax of an mxn matrix A times a vector x = (21, 12,..., In) can be computed row-wise as y = [A(1,:)*x; A(2,:)*x; ... ;A(m, :)*x]; that is y(1) = A(1,:)*x y (2) = A(2,:)*x y(m) = A(m, :)** 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 4 x 6 matrix A and a random 6 x 1 vector x. Compare the output with A*x. Repeat with a 5 x 3 matrix and a 3 x 1 vector and with a 5 x 3 matrix and a 1 x 3 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

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

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

1. Define mass and mediated communication

Answered: 1 week ago