Karhunen-Loeve Matlab code
By Matlab documentation for eig() function:

[V,D] = eig(A) returns diagonal matrix D of eigenvalues and matrix V
whose columns are the corresponding right eigenvectors, so that AV =
VD.

If I understood your question, in linked code, eig() is calculated m times in a loop (to get values for cell arrays v{m}, d{m}) when v2 and d2 holds results just from one eig() call.
EDIT:
I don't have the picture you used so, I tested code (from your link) with an image (cameraman.tif) found from here and got this data:

By results, v{1} and v{2} are:
&gt;&gt; v{1}
ans =

 Columns 1 through 6:

  -4.0138e-01  -1.4572e-02  -1.2048e-01   2.3176e-01   4.1139e-01  -3.1815e-01
   4.3686e-01  -1.2307e-01  -3.9978e-01   2.7047e-01   2.2728e-01   9.6813e-02
  -4.0138e-01  -1.4572e-02  -1.2048e-01   2.3176e-01   4.1139e-01  -3.1815e-01
   4.3686e-01  -1.2307e-01  -3.9978e-01   2.7047e-01   2.2728e-01   9.6813e-02
   2.9537e-01  -5.6967e-01   5.2108e-01   2.9155e-01  -1.0665e-01  -4.6940e-01
   3.6360e-01   5.5112e-01   5.2095e-01  -2.1498e-02   5.4056e-01   2.0849e-03
   2.5115e-01  -1.7181e-02  -2.8419e-01  -7.0205e-01   9.6838e-02  -5.9465e-01
   1.1653e-01   5.8372e-01  -1.6628e-01   4.0979e-01  -4.9522e-01  -4.5263e-01

 Columns 7 and 8:

  -3.8642e-01  -5.9218e-01
   5.9218e-01  -3.8642e-01
   3.8642e-01   5.9218e-01
  -5.9218e-01   3.8642e-01
  -2.1553e-16   2.7222e-16
  -1.8265e-16   2.3956e-16
  -3.8696e-16   2.5427e-16
  -1.0408e-16   9.0464e-17

&gt;&gt; v{2}
ans =

 Columns 1 through 6:

   9.0501e-02  -1.2846e-01   1.4943e-01  -2.9304e-01  -5.9191e-01   1.2941e-01
   3.8163e-01  -9.8168e-02  -4.8404e-02  -3.8589e-01   3.2360e-01   2.9791e-01
   9.0501e-02  -1.2846e-01   1.4943e-01  -2.9304e-01  -5.9191e-01   1.2941e-01
   3.8163e-01  -9.8168e-02  -4.8404e-02  -3.8589e-01   3.2360e-01   2.9791e-01
   4.6546e-01  -2.4078e-01   7.1522e-01   2.2122e-01   1.0894e-01  -3.9119e-01
   5.7975e-01   6.1828e-01  -3.3337e-01   7.0850e-03  -2.1081e-01  -3.5495e-01
   2.2974e-01   2.2265e-01   1.4556e-01   6.0005e-01  -1.1856e-01   7.0876e-01
   2.9460e-01  -6.7668e-01  -5.5389e-01   3.4841e-01  -1.3955e-01  -8.7478e-02

 Columns 7 and 8:

  -3.9894e-01  -5.8382e-01
  -5.8382e-01   3.9894e-01
   3.9894e-01   5.8382e-01
   5.8382e-01  -3.9894e-01
   4.1426e-16  -1.3694e-16
   2.5085e-16  -2.6656e-17
  -6.0554e-16   8.3807e-17
   6.6451e-17  -1.3088e-17

At which point you take the value for v2 and d2 since AFAIK, if you take them at &quot;position&quot; m then data should be equal with the mth one v's and m's?