1
$\begingroup$

What is the right way to declare of matrix whose coefficients are functions of a variable $x$ ?

I tried :

Table[Table[a[i,j][x_],{j,1,NN}],{i,1,NN}]
$\endgroup$
4
  • $\begingroup$ You can not use N as a variable change it.. $\endgroup$
    – user59583
    Apr 27, 2019 at 15:24
  • $\begingroup$ ok that was not the problem $\endgroup$
    – Smilia
    Apr 27, 2019 at 15:26
  • 1
    $\begingroup$ What about sth. like this: Table[Table[a[i, j, x_], {j, 1, 2}], {i, 1, 2}] $\endgroup$
    – user59583
    Apr 27, 2019 at 15:27
  • $\begingroup$ And what about Table[a[i, j][x_], {i, 1, NN}, {j, 1, NN}] ? Why two calls to Table ? $\endgroup$ Apr 28, 2019 at 14:19

2 Answers 2

3
$\begingroup$
f[x_, n_] := Table[Table[a[i, j, x], {j, 1, n}], {i, 1, n}]

for example

f[x, 4] // MatrixForm

enter image description here

$\endgroup$
1
$\begingroup$

It's worth knowing about the Array function which might be used like this:

Array[a[#1, #2][x_] &, {4, 4}]

This reproduces the output of OP's initial version (with NN set to 4). I'm not convinced that that is really what OP wants, so this variation

Array[a[#1, #2, x_] &, {4, 4}]

might also appeal.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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