4 views (last 30 days)

I would like to call a eigenvector of a matirx without calling its eigenvalues inside a function. Here I attach my code. Pl somebody help me.

function [out]=integration(hami1)

[V,L]=eig(hami1); %% Some error is here showing that L is unused in my code.

u=V(:,1)/sqrt(sum(V(:,1)));

w=diff(u,phi);

f=dot(u,w);

out=1/pi*1i*int(f,phi,0,2*pi);

end

Walter Roberson
on 1 Feb 2020

Given your question as asked, you will need to write your own code to somehow determine eigenvectors without calculating the corresponding eigenvalues.

However what you are seeing is a warning not an error, and most people would deal with it by coding

[V,~]=eig(hami1);

which tells MATLAB to tell eig that two outputs are requested (so that it knows to return eigenvectors in the first output), but that the second output will be ignored by the code.

Walter Roberson
on 1 Feb 2020

Sign in to comment.

Vladimir Sovkov
on 1 Feb 2020

- This is not an error but a warning that you do not use the eigenvalues, which influences nothing. If you want to avoid it, substitute the symbol "~" in place of "L".
- It looks that you use "phi" before defining it. This must be an error.
- Are you sure that your way of the eigenvector normalization is what you wanted? It looks quite unusual... The function "eig" is expected to produce the eigenvectors with unit algebraic norm already, at least for real symmetric matrices.

Vladimir Sovkov
on 1 Feb 2020

Vladimir Sovkov
on 1 Feb 2020

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.