I want to write a program in which I will read values from a loop e.g. a_k = \cos{nk/N}, where the loop will run from 1 to N and feed a_k at each step into a matrix. Then I want to use those values to diagonalize the matrix.
It would be better to use Table rather than a Do loop to construct your matrix. Also, I don’t see how you’ll construct a matrix since the formula you give as an example only has one index.
In[12]:= m = Table[i^2*(j + 1) + 2, {i, 5}, {j, 5}]
Out[12]= {{4, 5, 6, 7, 8}, {10, 14, 18, 22, 26}, {20, 29, 38, 47,
56}, {34, 50, 66, 82, 98}, {52, 77, 102, 127, 152}}
In[13]:= Eigenvalues[m]
Out[13]= {5 (29 + Sqrt[817]), 5 (29 - Sqrt[817]), 0, 0, 0}