Use matlab Write a wellcommented Matlab function program myi
Use matlab:
Write a well-commented Matlab function program ‘myinvcheck’ that • Makes a n×n random matrix (normally distributed, A = randn(n,n) ), • Calculates its inverse (B = inv(A)), • Multiplies A×B, Write a well-commented Matlab script program that calls ‘myinvcheck’ for n = 3, 5.
Solution
Main Program:
clc
 n=input(\'size of matrix (n)=\');%For fetching size of the matrix(n) from command window
 if n==3||n==5 %Executes whenever the n value is either 3 or 5
 myinvcheck(n); % Calling \'myinvcheck\' function
 end
myinvcheck function:
function C = myinvcheck;%creating the user defind function with the name \'myinvcheck\'
 clc
 A=randn(n,n) % Creating a matrix with random numbers of size n
 B=inv(A) % Calculation of inverse of the matrix A
 C=A*B % Product of matrices A and B
 end

