hw4ceg416wi10-old

hw4ceg416wi10-old - fid = fopen( 'bmat.txt' , 'r' ); BB =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1 of 1 CEG/MTH/416/616 Winter 2010 HW 4 CEG/MTH/416/616 Matrix Computations Homework Set # 4 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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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)'; fclose(fid); The first three elements of x are -1 -5 -4. Determine the output of the disp statements in the first code above. Use your modified version of thomas.m – call it spthomas.m. 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.

Ask a homework question - tutors are online