Problem on linear equations using Matlab

Use Matlab to solve the following system of linear equations:

2x + y + 3z = 1
2x + 6y + 8z = 3
6x + 8y + 18z = 5

Capture Matlab code and the result in a text file.

E

Expert

Verified

Calculations:

% The equations represent AX = B . where A is the 3*3 Matrix of the input

% values , X is the matrix representing the variables and B is the result

% matrix; Thus we need to find X,which = b* inverse(a) or B/A

A= [ 2 1 3; 2 6 8; 6 8 18];
B= [ 1 3 5];
X= B/A;

% result of x, y, z displayed

x= X(1)
y=X(2)
z=X(3)

% results written in a text file

csvwrite('result.txt',X);

% Content of the text file displayed

type result.txt

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.