Sorting eigenvectors using symbolic toolbox for PageRank algorithm
Show older comments
I wondering how I can sort the eigenvectors when I am using "d" as a symbolic from the symbolic toolbox? I tried using [U,D]= eig(vpa(M)), but that didn't work. Do I perhaps have to decide how the symbolic roots are sorted when solving for the eigenvectors? I am not quite sure how to do this in Matlab.
The code is given below where I have written a function and what I have in the script separately.
function [Vs] = pagerank_function(linkMatrix,d)
n = size(linkMatrix,1)
M = d * linkMatrix + (1-d)/n * ones(n)
% diagonal matrix eigenvalues D, eigenvectors mtx U
%[U,D]= eig(vpa(M))
[U,D] = eig((M))
[d,ind] = sort(diag(D))
Ds = D(ind,ind)
Vs = V(:,ind)
end
Which takes the following matrix
L2 = [0 1/2 1/3 0 0 0 0;
1/3 0 0 0 1/2 0 0;
1/3 1/2 0 1 0 0 0;
1/3 0 1/3 0 1/2 0 0;
0 0 0 0 0 0 0;
0 0 1/3 0 0 1 0;
0 0 0 0 0 0 1];
d = sym('d');
[Vs] = pagerank_function(L2,d);
The general goal I want to achieve is to study how the damping factor 'd' influences all the eigenvectors produced in 'pagerank_function'. Any help would be appreciated as I am quite new to matlab.
Accepted Answer
More Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
