Eigen values of a Toeplitz Matrix
Mostrar comentarios más antiguos
Hello. I have a problem finding the eig(T), my matrix have very very small numbers, my code is:
K=[];
M= [];
for i=0:512
M =[M,((-1)^(i))*combinatorio(3/4,i)]; %combinatorio is a function that i created to compute nchoosek(a,b) in real numbers
end
for i=0:512
if i==0
K=[K,((-1)^(i))*combinatorio(3/4,0)];
end
if i==1
K=[K,33];
end
if i >1
K = [K,0];
end
end
T=toeplitz (M,K);
E=eig(T)
When I do this for 512, it generates an error
Error using eig
Input matrix contains NaN or Inf.
I think that is becouse the values of the matrix are so small that MatLab thinks they are 0's. and have problems in eig(T), if you have an idea to solve this please help me with this. Thanks.
EDIT:
function [y1] = combinatorio(a,b)
c=a;
if b==0
y1=1;
end
if b~=0
for i=1:(b-1)
a=a*(c-i);
end
y1 = (a/factorial(b));
end
2 comentarios
Walter Roberson
el 20 de Mayo de 2018
It would help ifwe had your routine combinatorio
Juan Rodriguez
el 20 de Mayo de 2018
Respuestas (1)
Walter Roberson
el 20 de Mayo de 2018
0 votos
Your combinatorio finds (-1)^b*gamma(b-a)/gamma(-a) and then finds b! and divides the 2. But at b = 171, b! overflows representable doubles, resulting in inf.
You should reformulate so that in the loop you multiply a by (c-i)/(b+D) where D is -1, 0, or +1, depending on what you need for the factorial logic to work out.
Categorías
Más información sobre Random Number Generation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!