How can I make a guess sidel function with the given variables: GS(Am,bm,iโnitial_gueโss,10^-4) and the range is ๐ = [20, 40, 80, 160, 320, 640, 1280]
์กฐํ ์: 2 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
How can I make a guess sidel function with the given variables: GS(Am,bm,initial_guess,10^-4) and the range is ๐ = [20, 40, 80, 160, 320, 640, 1280]?
๋๊ธ ์: 0
๋ต๋ณ (1๊ฐ)
Ishan
2022๋
11์ 29์ผ
Hi Anujan,
If you want to solve a linear equation by Gauss-Seidel method, you can use the below function to do so:
%A = input('Enter a Co-effecient Matrix A: ');
A = [10 3 1;3 10 2;1 2 10];
%B = input('Enter Source Vector B: ');
B = [19;29;35];
%P = input('Enter initial Guess Vector: ');
P = [0;0;0];
%n = input('Enter no. of iterations: ');
n = 10;
%e = input('Enter your tollerance: ');
e = 0.0001
N = length(B);
X = zeros(N,1);
Y = zeros(N,1);
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('Iteration no. %d\n', j)
X
if abs(Y-X)<e
break
end
Y=X;
end
Hope this helps you solve your problem!
๋๊ธ ์: 0
์ฐธ๊ณ ํญ๋ชฉ
์นดํ ๊ณ ๋ฆฌ
Help Center ๋ฐ File Exchange์์ Discrete Math์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!