Let's say I have the following set of parameters:
param=
{a->1,b->2,c->3}
and the following function that uses the parameters:
func = a+b*x+c*x^2
I can apply the parameters to the function by the following assignment:
func /.param
1+2*x+3*x^2
Now I would like to change only the param c for some specific param, let's say:
c -> {10,22,23,1}
How can I create a new set of param, which should look like that in the end:
param = {
{a->1,b->2,c->10},
{a->1,b->2,c->22},
{a->1,b->2,c->23},
{a->1,b->2,c->1}
}
such that I can sweep through the parameters of c without having to retype every time the parameters from a and b ?
What I tried:
param ={
a->#[[1]],b->#[[2]],c->#[[3]]} &/@ {Table[1,{i,1,4}],Table[1,{i,1,4}],{10,22,23,1}}
but this did not work out + it is not very nice, as the variable i
has to be adjusted manually to the number of different c
values there exist.
func[a_, b_, c_][x_] := a + b x + c x^2; Table[func[1, 2, c][x], {c, {10, 22, 23, 1}}]
$\endgroup$func
is not a function; it is an expression. $\endgroup$Table
, you can doTable[...,{i, Length[cvalues]}]
, if you have your c values in a listcvalues
. $\endgroup$