Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB CODING Write a pentadiagonal solver starting from this code of a tridiagonal solver shown below. function x = Tridiag(e,f,g,r) % Tridiag: Tridiagonal equation solver

MATLAB CODING

Write a pentadiagonal solver starting from this code of a tridiagonal solver shown below.

function x = Tridiag(e,f,g,r)

% Tridiag: Tridiagonal equation solver banded system

% x = Tridiag(e,f,g,r): Tridiagonal system solver.

% input:

% e = subdiagonal vector

% f = diagonal vector

% g = superdiagonal vector

% r = right hand side vector

% output:

% x = solution vector

n=length(f);

% forward elimination

for k = 2:n

factor = e(k)/f(k-1);

f(k) = f(k) - factor*g(k-1);

r(k) = r(k) - factor*r(k-1);

end

% back substitution x(n) = r(n)/f(n);

for k = n-1:-1:1

x(k) = (r(k)-g(k)*x(k+1))/f(k);

end

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

EXPLAIN the typical steps in a grievance procedure.

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago