# Create a 3x3 matrix
A <- matrix(c(0,1,2,0.5,0.1,0,0,0.6,0.6), byrow=TRUE, ncol=3)
A
# Calculate the transfer function given a range of z and a perturbation structure
evals<-eigen(A)$values
lmax<-which.max(Re(evals))
lambda<-Re(evals[lmax])
z <- seq(lambda-0.04, lambda+0.04, 0.01)
z <- z[ z != lambda]
b <- matrix(c(0,0,1), ncol=1)
c <- matrix(c(0,0,1), ncol=1)
p<-1/tf(A, z=z, b=b, c=c)
p
## Plot p and z
plot(z~p,type="l", xlab="p",ylab=expression(lambda[max]))
Run the code above in your browser using DataLab