hw4ceg416wi10

# hw4ceg416wi10 - Important Add 2.0 to all the terms in...

This preview shows pages 1–3. Sign up to view the full content.

Page 1 of 1 CEG/MTH/416/616 Winter 2010 HW 4 CEG/MTH/416/616 Matrix Computations Homework Set # 4 Changes 2/21/10 see below. 50 points undergraduates and graduates. Assigned February 18, 2010. Due February 25, 2010. WebCT submittals of code. Problem 1 . (25 points) Modify the thomas.m code so that it works with the columns of the matrix output of the spdiags MATLAB function. Use the data in the file: http://www.cs.wright.edu/~rtaylor/ceg416/other/hw4/bmat.txt This data came from a screen copy of the B matrix output of this code: n = 150 ; A = round(7*randn(n,n)); x = round(6*randn(n,1)); A = A - tril(A,-2) - triu(A,2); b = A*x; B = [spdiags(A) b] %Note: make sure you understand disp( 'norm of x:' ); % each line of code. disp(norm(x)); disp(x(4)); disp(x(21)); The following code reads the bmat.txt file fid = fopen( 'bmat.txt' , 'r' ); BB = fscanf(fid, '%f' ,inf); nn = size(BB) %Note: same as Note above. m = nn(1)/4; BBNEW = reshape(BB,4,m)';

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Important: Add 2.0 to all the terms in column 2 of BBMNEW. fclose(fid); The first three elements of x are -1 -5 -4. The first three elements of x are -27.3716 1.3429 10.2887 Determine the output of the disp statements in the first code above. Use your modified version of thomas.m – call it spthomas.m. Discuss why the data as given (without adding 2.0 to column 2 of BBNEW), produces an error in the Thomas algorithm. Does this mean that there is no solution with the original BBNEW data? You should have a runspthomas.m which reads the bmat.txt file and prepares the data for spthomas.m. Submit spthomas.m and runspthomas.m files to WebCT. Problem 2 . (25 points) Write a new thomas which works with spdisp for an anti-tridiagonal matrix. Use the first six rows of the bmat.txt as your text case. Submit antispthomas.m and runantispthomas.m files to WebCT. Clearly show the x vector....
View Full Document

## This note was uploaded on 04/26/2010 for the course CEG 616 taught by Professor Taylor during the Winter '10 term at Wright State.

### Page1 / 3

hw4ceg416wi10 - Important Add 2.0 to all the terms in...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online