Show and explain how to solve cramer’s rule using Matlab.
Let us consider the following equations
x+2y+3z=14
2x+3y+5z=23
5x+3y+6z=14
MATLAB CODE-----
clc;
clear all;
close all;
a=[1 2 3;2 3 5;5 3 6];
b=[14;23;14];
x=ones(3,1);
a_determinant=det(a); %FOR FINDING DETERMINANT
%SO FOR FINDING THE ELEMENT AT X AT INDEX I.
%IT IS GIVEN BY RATIO OF TWO DETERMINANTS.
for i=1:3
c=a;
c(:,i)=b;
x(i,1)=det(c)/a_determinant;
end
disp('APPLYING CRAMERS RULE RESULT IS');
disp('x,y,z=');
disp(x);
Get Answers For Free
Most questions answered within 1 hours.