Answer to Question #327810 in MatLAB for lll

Question #327810

Write a MatLab program to find the value of ×, y and z using Gauss-Elimination method in

the following equations

2x+4y + 2 - 3;

3x+2y - 2z= -2;

x-y+z=6.


1
Expert's answer
2022-04-13T09:01:31-0400

%Gauss elimination method [m,n)=size(a);

a=[2 4 2 3

  3 2 -2 2

  1 -1 1 6];

[m,n]=size(a);

for j=1:m-1

  for z=2:m

    if a(j,j)==0

      t=a(j,:);a(j,:)=a(z,:);

      a(z,:)=t;

    end

  end

  for i=j+1:m

    a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));

  end

end

x=zeros(1,m);

for s=m:-1:1

  c=0;

  for k=2:m

    c=c+a(s,k)*x(k);

  end

  x(s)=(a(s,n)-c)/a(s,s);

end

disp('Gauss elimination method:');

a

x'



Result:

ans =


  2.8000

  -1.5000

  1.7000


>> 


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS