Can someone with experience with writing matlab code help me

Can someone with experience with writing matlab code help me out on this problem.
Implement the Gauss-Thomas Method (Page 117 to solve the linear system of equations appearing in problem C3.1 on Page 129. In your solution include a copy of the Gauss-Thomas Method script, a copy of any relevant data tables, and state a conclusion.

Solution

Matlab code:

% we need to create a matrix with the help of upperdiagonal, diagonal, lower diagonals.

a=[1 1 3 -2 -2 -2 0 0]; % is a upper diagonal vector with a(n)=0.

b=[0 -1 4 0 -2 -4 2 0]; % is a upper diagonal vector with b(1)=0.

d=[-1 4 1 -1 -2 -2 4 2]; % is a diagonal vector.

r=[7 13 -3 -2 -4 -28 26 10]; % is a right hand side vector.

Now we have to call a function thomas.m which gives a direct solution vector x

function x=thomas(a,b,d,r)
n=length(d);
a(1)=a(1)/d(1);
r(1)=r(1)/d(1);

for i=2:n-1
denom=d(i)-b(i)*a(i-1);
if (denom==0),error(\'zero in denominator\'),end
a(i)=a(i)/denom;
r(i)=(r(i)-b(i)*r(i-1))/denom;
end
r(n)=(r(n)-b(n)*r(n-1))/(d(n)-b(n)*a(n-1));
x(n)=r(n);
for i=n-1:-1:1
x(i)=r(i)-a(i)*x(i+1);
end

x

end

Output :

x=[-4.0000 3.0000 -3.0000 -4.0000 3.0000 3.0000 5.0000 5.0000]

Can someone with experience with writing matlab code help me out on this problem. Implement the Gauss-Thomas Method (Page 117 to solve the linear system of equa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site