# For loop to define a Matrix

Suppose I have a matrix,

Mat = MatrixForm[{{1.5, 2.83034}, {1.50476, 2.82655}}]


I need to define parameters such that in the matrix 'i'th component is 'Lambda' and 'j'th component is corresponding 'Neff' value.

How is that possible in Mathematica?

I tried this

   For[i = 0; j = 0, i < 21 ; j < 21, i++, j++; Map[LambdaSS[i], NefS1[j]] = Mat[i, j]]


However, this generates error.

• Don't use MatrixForm. It is only a wrapper meant for display purposes. – Henrik Schumacher Feb 12 '19 at 10:41
• And, almost certainly, the sub-expression Map[...] is going to cause grief later. Is the assignment the wrong way round ? OP might want to investigate the Array function for programmatic construction of arrays. – High Performance Mark Feb 12 '19 at 11:23
• Moreover, indexing into a matrix has to be done with Part, so it should be Mat[[i,j]]. See also The Four Kinds of Bracketing in the Wolfram Language. Moreover, For loops are evil. – Henrik Schumacher Feb 12 '19 at 11:49
• @HenrikSchumacher : I removed the MatrixForm. I understand the indexing using Part. However, here I don't need to index individiual entries in the matrix. I want to have a standard definition which signifies that Matrix [LambdaSS, NefS1] = Mat[[i,j]. – user35115 Feb 14 '19 at 11:15
• @HighPerformanceMark: Thanks for your inputs. Actually, I need to plot a function with variable LambdaSS. The values of LambdaSS should be limited to the arrray. That is to say it can only take 2 values 1. 5 and 1.50476 if we were to consider the above array – user35115 Feb 15 '19 at 7:56

I'm not certain that I understand what you are trying to do @user35115, but if I did, this works for any functions f1 and f2 (defined by you or native to Mathematica).

f1[i_] := i^2;
f2[i_] := i^3 - f1[i];
matrix = Array[a, {1, 2}];
matrix[[1, 1]] = f1;
matrix[[1, 2]] = f2;
m = Array[b, {1, 2}];
For[i = 1, i < 21, i++,
m[[1, 1]] = f1[i];
m[[1, 2]] = f2[i];
matrix = Join[matrix, m];
];