# proj4 - 3 Write a MATLAB function P=eigbasis(A which...

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

MATLAB Project 4 for MAS 3114 Due Wednesday, December 7 1. Write a MATLAB function m=mult(A,ev) which accepts as inputs an n × n matrix A and a (possibly complex) number ev , and gives as output the algebraic multi- plicity m of ev as an eigenvalue of A . (If ev is not an eigenvalue of A then m=0 .) The MATLAB function eig(A) may be useful here. To guard against roundoF errors, you should consider the eigenvalues λ 1 and λ 2 to be equal if | λ 1 - λ 2 | < 10 - 7 . Apply mult to each of the following matrices, with ev1=0 and ev2=2 : A = [2 2 3; 0 3 -1; 0 2 0] B = [3 2; -2 3] C = magic(6) D = reshape(1:25,5,5) E = rand(4,4) F = diag([1 0 0 0],1)+diag([2 2 2 4 4]) 2. Write a MATLAB function d=disteig(A) which accepts as input an n × n ma- trix A , and gives as output a vector whose entries are the distinct eigenvalues of A . In other words, each eigenvalue of A should occur just once as an entry of d=disteig(A) . As in problem 1, you should consider the eigenvalues λ 1 and λ 2 to be equal if | λ 1 - λ 2 | < 10 - 7 . Apply disteig to each of the matrices in problem 1.

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: 3. Write a MATLAB function P=eigbasis(A) which accepts as input an n × n ma-trix A and gives as output an n × n invertible matrix P whose columns are eigen-vectors for A . The matrix P may have complex entries. If A is not diagonaliz-able then your function should give an appropriate error message. Your function should not rely on any built-in MATLAB functions for ±nding eigenvectors, such as [V,D] = eig(X) . Once again we must beware of problems with roundoF er-rors. Therefore you should use the program newnullbase (given on the back of the page) instead of nullbase (or rref ). Apply the function eigbasis to each of the matrices in problem 1. function B=newnullbase(A) [m,n]=size(A); [R,jb]=rref(A,10^(-7)); r=length(jb); d=n-r; l=zeros(1,n); l(1,jb)=ones(1,r); l=logical(l); k=~l; B=zeros(n,d); if d>0, B(l,:)=-1*R(1:r,k); B(k,:)=eye(d); end...
View Full Document

## This note was uploaded on 12/27/2011 for the course MAS 3114 taught by Professor Olson during the Fall '08 term at University of Florida.

### Page1 / 2

proj4 - 3 Write a MATLAB function P=eigbasis(A which...

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

View Full Document
Ask a homework question - tutors are online