Question: ** Create a function in MATLAB: function [C, N] = solvesys(A) First, check whether A is invertible. If not, the function returns an empty matrix

 ** Create a function in MATLAB: function [C, N] = solvesys(A)

** Create a function in MATLAB: function [C, N] = solvesys(A) First, check whether A is invertible. If not, the function returns an empty matrix C=[], an empty vector N=[], and a message "The system is either inconsistent or the solution is not unique". If A is invertible, the function solves the equation Ax = b using the three methods described above and gives the output vectors x1. x2, x3 for each of the methods (1)-(3), respectively. The vectors have to be the columns of the matrix C, that is, we assign C=[x1, x2, x3]. Input will be an n times n matrix A. Vector b = fix(10*rand(n, 1)) has to be placed in the code and displayed (do not put semicolon after typing b = fix(10*rand(n, 1)) in your function). Use the command format long (% to display number in exponent format with 15 digit mantissas) within your function. **The function [C, N] =solvesys(A) also returns vector N = [n1; n2; n3] with n1 = norm(x1 - x2), n2 = norm (x2 - x3), n3 = norm (x3 - x1). Each entry of the vector N is the 2-norm of the vector of the difference between two different solutions (calculated as a squareroot of the sum of squares of the entries - a built-in MATLAB function norm). The vector N gives an idea "how different" are the solutions obtained by various methods. **Type the function solvesys in your diary file. **Run the function [C, N] =solvesys(A) for the following choices of the matrix A: (a) A = magic(6), (b) A = eve(5), (c) A = randi(20, 4, 4), (d) A = magic(3), (e) A = hilb(6). % Comment on the output for part (b) - compare the solution with the vector b. % Explain in your dairy file why the norms of the differences between the solutions for matrix in (e) is so big compared with the ones for matrices in (b)-(d). It might be helpful to calculate the determinant of hilb(6) and see how close it is to 0. You can also run MATLAB: help hilb (do not put it in your diary file) to have an idea what type of matrices the Hilbert matrices are

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!