Write a wellcommented Matlab function program mysolvecheck w
Write a well-commented Matlab function program mysolvecheck with input a number n that makes a random n × n matrix A and a random vector b, solves the linear system Ax = b, calculates the norm of the residual r = Ax b, and outputs that number as the error e
Solution
%taking input
 n = input(\'Enter n: \');
%creating a random matrix A of nXn
 A = rand(n, n);
%creating a random matrix b of nX1
 b = rand(n, 1);
%calculating x using inverse(A) * b
 x = A\\b;
%calculatin r
 r = A*x-b;
%calculating norm of r
 e = norm(r);
%displaying error
 disp([\'e = \', num2str(e)]);

