Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I think that I answered #1 below is my code. Could you please confirm if this is correct and and if it's not make the

I think that I answered #1 below is my code. Could you please confirm if this is correct and and if it's not make the changes neccessary and then use it to solve #2?

1function x = linear_ngaussel(A,b)

2% A = n x n matrix

3% b = column vector, n x 1

4n=length(b);

5x=zeros(n,1);

6% Perform the forward elimination

7for k=1:n-1

8 for i=k+1:n

9 m=A(i,k)/A(k,k);

10 for j=k+1:n

11 A(i,j)=A(i,j)-m*A(k,j);

12 end

13 b(i)=b(i)-m*b(k);

14 end

15end

16% Perform the back substitution

17x(n)=b(n)/A(n,n);

18for i=n-1:-1:1

19 S=b(i);

20 for j=i+1:n

21 S=S-A(i,j)*x(j);

22 end

23 x(i)=S/A(i,i);

24end

image text in transcribed

1. Write a code in Matlab to solve a linear system of equations of any size using the simple Gauss Elimination algorithm 2. Using your code in (2) to find x, y, and z for the system of equations: 3x 4y + 2z = 1 2x+3y-3z = -1 5x 5y + 4z = 7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions