Eigenvector without calling eigenvalues
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Walter Roberson
2020-2-1
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.
3 个评论
Walter Roberson
2020-2-1
integral() cannot call scripts so the relative speeds of scripts and functions is not relevant to the situation.
更多回答(1 个)
Vladimir Sovkov
2020-2-1
- 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.
7 个评论
Vladimir Sovkov
2020-2-1
This is problem-dependent. Sometimes it is correct, sometimes not. You can just calculate the norm of your case and see if it equals 1 or not. Maybe, you are right and this re-normalization is really needed. Anyway, it would not spoil the results, and maybe safer to keep it in the program.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!