Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

What is the Bank of Canadas monetary policy objective?

Answered: 1 week ago