How can I do this write a MATLAB function that takes two mat
How can I do this?
write a MATLAB function that takes two matrices A and B as input and returns
A * B if A and B are conformable, and returns the empty matrix [] otherwise;
You may not use the built in * operator for matrices – only scalars, so you will need to use the definition of matrix multiplication and one loop (column) nested in another loop (row).
Outline:
Create a SINGLE MATLAB Script .m file
Clearly label which problem is being done in a comment line / block
Write the necessary MATLAB commands to meet the specification of each problem given above
Make sure to test your code / “program” when it is done
You really need to run your program a number of time to do this thoroughly
Solution
Two matrix are conformable for the multiplication if the number of rows in one matrix is equal to numer of columns in other matrix and number of columns in one matrix is equal to number of columns in other matrix.
Function mat = mult(A,B)
[row1,col1] = size(A)
[row2,col2] = size(B)
if row1 == col2 and row2 == col1
return
else
mat = []
return
