Question: Numerical Methods: Using the given Matlab code that solves a 10 by 10 tridiagonal system of equations, edit the Matlab code so that it solves

Numerical Methods:

Using the given Matlab code that solves a 10 by 10 tridiagonal system of equations, edit the Matlab code so that it solves a 10 by 10 block (2 x 2) tridiagonal system of equations.

I wrote this program for a previous problem that solves 10 by 10 tridiagonal system of equations and it works great!!! I am having difficulties editing and rewriting the program so that it solves a 10 by 10 block (2 x 2) tridiagonal system of equations. Please use and work with the provided Matlab code. Thank you!

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

% Solving a tri-diagonal systems of equations.

clear all

clc

% Size and dimension of matrix (n x n).

n=10;

% Generate n random values for the tridiagonal a(i) and the final resulting vector d(i).

for i=1:n

a(i)=rand;

d(i)=rand;

end

% Generate n-1 random values for superdiagonal b(j) and subdiagonal c(j-1).

for j=1:n-1

b(j)=rand;

c(j+1)=rand;

end

tau(1)=1/a(1);

delta(1)=d(1);

% Forward sweep.

for k=2:n;

tau(k)=1/(a(k)-(c(k)*tau(k-1)*b(k-1)));

delta(k)=d(k)-(c(k)*tau(k-1)*delta(k-1));

end

% Backward sweep.

x(n)=tau(n)*delta(n);

for k=1:n-1;

j=n-k;

x(j)=tau(j)*(delta(j)-b(j)*x(j+1));

end

% Values of matrix A.

A=[a(1) b(1) 0 0 0 0 0 0 0 0;

c(2) a(2) b(2) 0 0 0 0 0 0 0;

0 c(3) a(3) b(3) 0 0 0 0 0 0;

0 0 c(4) a(4) b(4) 0 0 0 0 0;

0 0 0 c(5) a(5) b(5) 0 0 0 0;

0 0 0 0 c(6) a(6) b(6) 0 0 0;

0 0 0 0 0 c(7) a(7) b(7) 0 0;

0 0 0 0 0 0 c(8) a(8) b(8) 0;

0 0 0 0 0 0 0 c(9) a(9) b(9);

0 0 0 0 0 0 0 0 c(10) a(10)]

% Values of vector d.

d=[d(1);d(2);d(3);d(4);d(5);d(6);d(7);d(8);d(9);d(10)]

% Values of the solution vector x.

x=[x(1);x(2);x(3);x(4);x(5);x(6);x(7);x(8);x(9);x(10)]

% Check if the Matlab code and the computed values of solution vector x are correct.

x_check=A^(-1)*d

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!