Solutions A system of linear algebraic equations can be written in matrix notation by applying the definition of matrix multiplication, For example, the linear system: 3x - 2y = 5 2x + 4y = -2 Can be written as or Ax = where A b= and x = 6
Code has already been provided to define a function named matrixInterpreter that accepts a 2 x 2 matrix input for the variable A and a 2x 1 matrix input for the variable b. The function command defines the output variable linear System. Add commands to use the values in the input variables A and b to build a single column cell array of character vectors where the first cell contains a character vector defining the first equation in the system and the second cell contains a character vector defining the second equation in the system. Assign this string to the output variable linear System. Do not insert any spaces in the character vectors defining the equations. For example, with the above system of equations example, the function inputs would be defined as A = (3-2; 2 41; [5; -21; The cell array output of the function would be linearSystem = {'3x-2y=4'; '2x+4y=-2'}; Your code should work for any integer values of the inputs A and b including possible negative values in order to pass all b = the test cases
1 function (linearSystem] = matrixInterpreter(a, b) 2 %Enter the commands for your function here. Be sure to assign values 3 %to the output variable linear System defined in the function command on line 1. 4 linearSystem{1,1} = sprintf("%dx®+dy=%d', , (1,1)); 5 linearSystem{2,1} = sprintf('. b(2,1)); Code to call your function © Roset 1 A = 13 -2; 2.41; 2 b = 15; -2]; 3 linearSystem = matrixInterpreter(A, b)
Matrix Notation Interpreter (matrix elements to cell array of formatted character vectors) My Matrix Notation Interpreter (matrix elements to cell array of formatted character vectors) My Solutions A system of line
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am