1

I have a matrix mainmatrix which must be multiplied by a (a={0.1, 0.2, 0.3,....1}). In any iteration, we have to save the matrix's eigenvalues in a list.

I wrote the code

mainmatrix={{-1, 1, 0, -1, -1}, {-1, -1, 1, -1, -1}, {-1, 1, -1, -1, 0}, 
{0, 1, -1, -1, -1}, {-1, 1, -1, -1, 1}};

Do[list[10 i + 1]=Eigenvalues[i*mainmatrix],{i, 0, 1, 0.1}]

But when read the list[1] or list[2] or any of them I see nothing!! Where am I making a mistake?

kglr
  • 394,356
  • 18
  • 477
  • 896
Inzo Babaria
  • 1,513
  • 7
  • 11
  • I think I should use Round[10*i+1] – Inzo Babaria Jun 05 '17 at 08:11
  • 4
    Three comments: First, you may find it more convenient to just store the results in a list, rather than in a function -- ie alllists=Table[Eigenvalues[i*mainmatrix],{i,0,1,0.1}]. Second, if you multiply a matrix by a constant, the eigenvalues just scale. Third, for your code, try list[1.]. – Erich Mueller Jun 05 '17 at 12:38

1 Answers1

2

The problem is rising from the 10*i+1 we have to use

Do[ list[Round[10i+1]]=Eigenvalues[i*mainmatrix],{i,0,1,0.1}]

Inzo Babaria
  • 1,513
  • 7
  • 11