Available Courses
Study Groups
Blog
Computational and Applied Mathematics Discussion Group
Login to ask or answer a question
Back to group
Belardina Zunguza (University of Witwatersrand, South Africa (ZA))

General question question in Numerical Techniques

Someone please help me with the code for Gauss-Seidel in matlab?

March 15 2013, 4:24 pm

ALL ANSWERS
Wayde Flowerday (University of Witwatersrand, South Africa (ZA))
I did this five years back. I have this code on my PC; I don't know if this helps at all.

clear all
clc
t1=-5:0.5:5;
t2=-5:0.5:5;
m1=length(t1);
m2=length(t2);
for i=1:m1;
for j=1:m2;
mat1(i,j)=1-3.*t1(i) t2(j);
mat2(i,j)=(1/2).*(-t1(i)-6.*t2(j));
mat3(i,j)=(1/7).*(4-4.*t1(i)-3.*t2(j));
end
end
mesh(t1,t2,mat1);
hold on;
mesh(t1,t2,mat2);
mesh(t1,t2,mat3);
%seidel%
n=20;
for i=1:n;
x1(1)=1;
x2(1)=1;
x3(1)=1;
x1(i 1)=(1/3).*(1 x2(i)-x3(i));
x2(i 1)=(1/6).*(-x1(i 1)-2.*x3(i));
x3(i 1)=(1/7).*(4-4.*x1(i 1)-3.*x2(i 1));
end
plot3(x1,x2,x3);


March 19 2013, 10:06 am


1

You have to log in to respond to this question.

©2018 - IQMates — all rights reserved | About Us | Terms of Service