x = {{a + b, b*c}, {c + d, d + (a + c)}}
numx = RandomReal[{0, 1}, {Length[Variables[x]]}]
x /. {a -> numx[[1]], b -> numx[[2]], c -> numx[[3]], d -> numx[[4]]}
Is there a better (more efficient) way to do this?
x = {{a + b, b*c}, {c + d, d + (a + c)}}
numx = RandomReal[{0, 1}, {Length[Variables[x]]}]
x /. {a -> numx[[1]], b -> numx[[2]], c -> numx[[3]], d -> numx[[4]]}
Is there a better (more efficient) way to do this?
The following keeps you from having to write out the set of rules in the final expression and so may be valuable for more complicated situations:
x = {{a + b, b*c}, {c + d, d + (a + c)}};
replacements = Thread [Variables[x] -> RandomReal[{0, 1}, {Length[Variables[x]]}]];
x /. replacements
--David
http://scientificarts.com
Just another way:
x = {{a + b, b*c}, {c + d, d + (a + c)}};
rep = # -> RandomReal[] & /@ Variables[x];
x /. rep