I have a question relate to Gauss seidel method
Implement the Gauss-Seidel method for solving a system of linear equations from scratch in MATLAB and walk me through your thought process in constructing the code. Additionally, demonstrate that your implementation works by applying it to the following system. 2x +3y −z =7 , x −2y+4z =1 , 3x +y+2z =8
%Gauss seidel
A=input(‘Enter a co-efficient matrix A: ‘);
B=input(‘Enter source vector B: ‘);
P=input(‘Enter initial guess vector: ‘);
n=input(‘Enter number of iterations: ‘);
e=input(‘Enter tolerance: ‘);
N=length(B);
X=zeros(N,1);
Y=zeros(N,1); %for stopping criteria
for j=1:n
for i=1:N
x(i)=(B(i)/A(i,i))-(A(i,[1:i-1,i+1:N])*P([1:i-1,i+1:N]))/A(i,i);
P(i)=X(i);
end
fprintf(‘Iterations no %d n’ ,j)
X
if abs (Y-X)<e
break
end
Y=X;
end
This is my code is this correct? please help meImplement the Gauss-Seidel method for solving a system of linear equations from scratch in MATLAB and walk me through your thought process in constructing the code. Additionally, demonstrate that your implementation works by applying it to the following system. 2x +3y −z =7 , x −2y+4z =1 , 3x +y+2z =8
%Gauss seidel
A=input(‘Enter a co-efficient matrix A: ‘);
B=input(‘Enter source vector B: ‘);
P=input(‘Enter initial guess vector: ‘);
n=input(‘Enter number of iterations: ‘);
e=input(‘Enter tolerance: ‘);
N=length(B);
X=zeros(N,1);
Y=zeros(N,1); %for stopping criteria
for j=1:n
for i=1:N
x(i)=(B(i)/A(i,i))-(A(i,[1:i-1,i+1:N])*P([1:i-1,i+1:N]))/A(i,i);
P(i)=X(i);
end
fprintf(‘Iterations no %d n’ ,j)
X
if abs (Y-X)<e
break
end
Y=X;
end
This is my code is this correct? please help me Implement the Gauss-Seidel method for solving a system of linear equations from scratch in MATLAB and walk me through your thought process in constructing the code. Additionally, demonstrate that your implementation works by applying it to the following system. 2x +3y −z =7 , x −2y+4z =1 , 3x +y+2z =8
%Gauss seidel
A=input(‘Enter a co-efficient matrix A: ‘);
B=input(‘Enter source vector B: ‘);
P=input(‘Enter initial guess vector: ‘);
n=input(‘Enter number of iterations: ‘);
e=input(‘Enter tolerance: ‘);
N=length(B);
X=zeros(N,1);
Y=zeros(N,1); %for stopping criteria
for j=1:n
for i=1:N
x(i)=(B(i)/A(i,i))-(A(i,[1:i-1,i+1:N])*P([1:i-1,i+1:N]))/A(i,i);
P(i)=X(i);
end
fprintf(‘Iterations no %d n’ ,j)
X
if abs (Y-X)<e
break
end
Y=X;
end
This is my code is this correct? please help me @wantquickhelp MATLAB Answers — New Questions