2
$\begingroup$

This is a minimal example of what I want to make work:

ClearAll["Global`*"]
coeff = Array[a, 2];
arange = {#, -1, 1} & /@ coeff;
X = Table[Indexed[x, i], {i, 1, 2}];
Manipulate[
coeff = Array[a, 2];
{coeff[[1]] X[[1]] + coeff[[2]] X[[2]], 
a[1] X[[1]] + a[2] X[[2]]},
##] & @@ arange

I would like to make the first option, namely coeff[[1]] X[[1]] + coeff[[2]] X[[2]] work like a[1] X[[1]] + a[2] X[[2]]. However, only the latter updates the values of the parameters.

context: I generate a system of ODEs with a large number of parameters. These parameters are generated via Array, and I'd like to put such a system into a Manipulate. Generating them via Array is very useful and convenient because the indices are used to define the equations.

$\endgroup$

1 Answer 1

3
$\begingroup$

This seems to work :

With[{coeff = Array[a, 2]},
 Manipulate[{coeff[[1]] X[[1]] + coeff[[2]] X[[2]]
    ,a[1] X[[1]] + a[2] X[[2]]}, ##]] & @@ arange  

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks indeed. For some reason logic would tell me that the coeff=Array[a,2] inside the Manipulate would be equivalent... of course, my logic is wrong. $\endgroup$
    – PepeToro
    Aug 24, 2023 at 15:01

Your Answer

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

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