PLEASE USE MATLAB TO SOLVE THAT QUESTION THANKS Create an
********* PLEASE USE MATLAB TO SOLVE THAT QUESTION, THANKS ********
Create an M-file to solve an n*n system of equations using Cramer\'s method. It should be a function which takes coefficients of the system and constant terms as input and gives the values of unknowns. Send your HW to this email address: afshin.shamsshooli@mavs.uta.edu a1101 a21 x 1 a12*2 a22T2 2 bm amiT1 am2T2Solution
program:-
clc
clear all
n=input(\' enter number of variables\');
e=input(\'number of equations\');
if (n>e || n<e),
disp(\'system is inconsisstent\');
else
disp(\'system is consisstent\');
disp(\'enter the constants of the equation one bye one\')
for i=1:n,
for j=1:n,
A(i,j)=input(\'enter the coeficents one by one=\');
end
b(i)=input(\'enter equation right side constant=\');
disp(\'go for the next equation\');
end
if det(A)==0,
disp(\'no solution\');
else
for i=1:n,
s=A;
s(:,i)=b;
x(i)=(det(s)/det(A));
disp(\'x\');
disp(x);
end
end
end
result:
%for quetion no.1
enter number of variables3
number of equations3
system is consisstent
enter the constants of the equation one bye one
enter the coeficents one by one=3
enter the coeficents one by one=2
enter the coeficents one by one=-1
enter equation right side constant=1
go for the next equation
enter the coeficents one by one=2
enter the coeficents one by one=-2
enter the coeficents one by one=4
enter equation right side constant=-2
go for the next equation
enter the coeficents one by one=-1
enter the coeficents one by one=0.5
enter the coeficents one by one=-1
enter equation right side constant=0
go for the next equation
x
1.0000 -2.0000 -2.0000
>>
%for question no.2
enter number of variables3
number of equations2
system is inconsisstent
%for question no.3
enter number of variables2
number of equations2
system is consisstent
enter the constants of the equation one bye one
enter the coeficents one by one=3
enter the coeficents one by one=2
enter equation right side constant=6
go for the next equation
enter the coeficents one by one=3
enter the coeficents one by one=2
enter equation right side constant=12
go for the next equation
no solution

