On Oct 8, 9:40 pm, "Jeff " <spREMOVEHITSjef...@SIGNoptonline.net>
wrote:
> I tried to describe "wrong" as best I could. Unfortunately, half of the explanation was before my code, and half was after. Also, I'm still learning this stuff, and trying not to include too much or too little info, at the same time as trying to learn Matlab. Thanks for bearing with me.
>
> The short version: I need the eigenvalues of matrix A (below) given in the order of the eigenvectors of A, which are listed in matrix Fxfrm.
>
> First, picture my Picture my data as this vertical vector:
> U=[u(1);u(2);u(3);u(4);u(5);u(6);u(7);u(8)];
>
> That data was created in the ode45 solver by the system represented by this matrix:
> A=2*eye(N)+diag(ones(N1,1),1)+diag(ones(N1,1),1);
> A(1,N)=1;A(N,1)=1;
>
> To calculate the potential energy in regular space, I would use the equation:
> Epot=(u(n+1)u(n))^2;
> and sum for all n=1..N.
>
> The fast Fourier transform, as implemented by Matlab, can be envisioned as a matrix, Fxfrm, something like this:
>
> w=exp(2*pi*i/N);
> for m=1:N,for n=1:N,Fxfrm(m,n)=w^((m1)*(n1));end,end
>
> This is easier to visualize:
> Fxfrm=
> [ 1, 1, 1, 1, 1, 1, 1, 1]
> [ 1, w, w^2, w^3, w^4, w^5, w^6, w^7]
> [ 1, w^2, w^4, w^6, w^8, w^10, w^12, w^14]
> [ 1, w^3, w^6, w^9, w^12, w^15, w^18, w^21]
> [ 1, w^4, w^8, w^12, w^16, w^20, w^24, w^28]
> [ 1, w^5, w^10, w^15, w^20, w^25, w^30, w^35]
> [ 1, w^6, w^12, w^18, w^24, w^30, w^36, w^42]
> [ 1, w^7, w^14, w^21, w^28, w^35, w^42, w^49]
>
> Note that the eigenvectors of A are the columns of Fxfrm (because A is circulant).
>
> If I multiplied Fxfrm times my data (Fxfrm on the left), I get my data in Fourier space (or frequency space):
> X=[x(1);x(2);x(3);x(4);x(5);x(6);x(7);x(8)];
>
> Now, I need to calculate the potential energy in frequency space, using, essentially, this equation:
> lambda=eig(A);
> Fpot=x(n)^2 * lambda(n)^2;
> where lambda_n is the nth eigenvalue of A.
>
> That is lambda(1) should be the eigenvalue associated with column 1 of Fxfrm; lambda(2) should be the eigenvalue associated with column 2 of Fxfrm, etc. But lambda=eig(A) returns the eigenvectors in declining magnitude order. I need the eigenvalues of A in the same order as the eigenvectors of A are listed in Fxfrm.
>
> Thanks, again.
> J
>
> P.S. Isn't there a better, more Matlaby (vectorized) way to create Fxfrm than my nested for loops and a more vectorized way create A?
You can't rely on producing any specified order with eig or eigs
rand('state',0)
for i = 1:20
x = rand(3);
y = eig(x);
z = eigs(x);
result = [yz y z ]
end
Hope this helps.
Greg
