0
$\begingroup$

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.

$\endgroup$
7
  • 4
    $\begingroup$ Don't use MatrixForm. It is only a wrapper meant for display purposes. $\endgroup$ – Henrik Schumacher Feb 12 '19 at 10:41
  • 2
    $\begingroup$ 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. $\endgroup$ – High Performance Mark Feb 12 '19 at 11:23
  • 2
    $\begingroup$ 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. $\endgroup$ – Henrik Schumacher Feb 12 '19 at 11:49
  • $\begingroup$ @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]. $\endgroup$ – user35115 Feb 14 '19 at 11:15
  • $\begingroup$ @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 $\endgroup$ – user35115 Feb 15 '19 at 7:56
0
$\begingroup$

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[0];
matrix[[1, 2]] = f2[0];
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];
];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.