Hi everybody: I have a 4x4 matrix M
see below, where for each value of h
I have corresponding a,b,c,d
values (please see the link below). I need to evaluate the matrix M
for each value of h
and corresponding a,b,c,d
to determine the eigenvalue and eigenvectors and save them in .txt file. So far, I have tried following way, where I can compute the said matrix by specifying the values separately but I couldn't set up a loop. I would really appreciate any help.
In this file, for each value of h we have a, b, c and d values.
Thanks in advance.
`
Mode1 = Import["CF.txt", "Table"];
M = {{h, 0, a, c}, {0, h, d, b}, {a, c, h/2, 0}, {b, d, 0, h/2}};
{eigs, vecs} = Eigensystem[M];
list1 = Partition[Riffle[eigs, Chop[vecs]], 2];
list2 = Sort[list1, #1[[1]] < #2[[1]] &];
list2 // MatrixForm
`
f[v_]:=Sort[v,N[#1[[1]]]<N[#2[[1]]]&]; Mode1=Import["CF.txt","Table"]; Map[({h,a,b,c,d}=#; M={{h,0,a,c},{0,h,d,b},{a,c,h/2,0},{b,d,0,h/2}}; {eigs,vecs}= Eigensystem[M]; list1=Partition[Riffle[eigs,Chop[vecs]],2]; list2=f[list1]; list2 // MatrixForm)&, Mode1]
and verify it is doing the assignment correctly for you $\endgroup$Export["CF.dat", list2]
within a Map, it will generate multiple files equivalent to the values of h, when I introduce outside of Map function it will generate only last eigenvalues and eigenvectors. Is it possible, that we can write all the values corresponding to each h in one file. $\endgroup$