Using MATLAB solve the following equation first using matrix
Using MATLAB, solve the following equation, first using matrix arithmetic, then using Cramer\'s Rule.
2tan(x)+6cos(y)+ln(z)=6
4tan(x)-3cos(y)-5ln(z)=-5
6tan(x)+9cos(y)+2ln(z)=11
Solution
Code:
% Solve a set of simultaneous equations using matrix arithmetic
 clc;
 clear all;
 A = [2 6 1;4 -3 -5;6 9 2];
 B = [6;-5;11];
 C = A\\B;
 x = 180*atan(C(1))/pi();
 y = 180*acos(C(2))/pi();
 z = exp(C(3));
 disp(\'Solution using Matrix Arithmetic:\');
 disp(x);
 disp(y);
 disp(z);
 %% Solve a set of simultaneous equations using Cramer Rule
 a = det(A);
 a1 =[6 6 1;-5 -3 -5;11 9 2];
 a2 =[2 6 1;4 -5 -5;6 11 2];
 a3 =[2 6 6;4 -3 -5;6 9 11];
 x1 =det(a1)/a;
 x2 =det(a2)/a;
 x3 =det(a3)/a;
 xx = 180*atan(x1)/pi();
 yy = 180*acos(x2)/pi();
 zz = exp(x3);
 disp(\'Solution using Cramer Rule:\');
 disp(xx);
 disp(yy);
 disp(zz);
Solution :
Solution using Matrix Arithmetic:
 26.5651
48.1897
2.7183
Solution using Cramer Rule:
 26.5651
48.1897
2.7183

