Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 1: New Matrices Write a function called makemat that will receive two column vectors as input arguments, and from them create and return a
Task 1: New Matrices Write a function called makemat that will receive two column vectors as input arguments, and from them create and return a matrix with two columns (n x 2). If either of both of the vectors passed in are row vectors, transpose them into column vectors. If either input is a matrix, your program should throw a unique error (Create your own error message). You may not assume that the length of the vectors is known. Also, the vectors may be of two different lengths. If that is the case, add O's to the end of one vector first to make it as long as the other (This is often referred to as padding the matrix with Os - do not use any built-in functions such as padarray(). Some examples of calling the function and the result you should see: >> makemat ([1;2;3;4], [5; 6; 7;8]) ans = 1 1 2 3 4 5 6 7 8 >> makemat([1,3,5], [2,4,6,8]) ans = 1 2 34 5 6 >> makemat ([1,2;3,4],[5,6,7]) Error using makemat (line 6) Can't process a matrix, try again. Undefined for matrix input arguments Figure 1: Some examples of calling the makemat function Task 2: Sum Matrices Write a function called sumMatrix that will receive the matrix generated in Task 1 and add all the values in the matrix and returns that value. You need to index appropriately and use loops to achieve this
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started