function [senmat, elasticity] = sensitivity(a) % [s,e] = sensitivity(a) % % Given Leslie matrix a, finds the corresponding % sensitivity matrix, s, and the elasticity matrix, e. % [w,d] = eig(a); d = diag(d); v = conj(inv(w)); imax = find(d==max(d)); w1 = w(:,imax); v = real(v(imax,:)).'; senmat=v*w'; elasticity = (1/imax)*senmat.*a;