WOLFRAM COMMUNITY
Connect with users of Wolfram technologies to learn, solve problems and share ideas
Join
Sign In
Dashboard
Groups
People
Message Boards
Answer
(
Unmark
)
Mark as an Answer
WOLFRAM COMMUNITY
Dashboard
Groups
People
0
|
4172 Views
|
2 Replies
|
0 Total Likes
View groups...
Follow this post
Share
Share this post:
GROUPS:
Mathematica
Wolfram Language
Numerical Computation
Quickly simulate values and evaluate
Casper YC
Casper YC, Kent
Posted
10 years ago
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?
POSTED BY:
Casper YC
Reply
|
Flag
2 Replies
Sort By:
Replies
Likes
Recent
0
Mark Dooris
Mark Dooris
Posted
10 years ago
Just another way:
x = {{a + b, b*c}, {c + d, d + (a + c)}};
rep = # -> RandomReal[] & /@ Variables[x];
x /. rep
POSTED BY:
Mark Dooris
Reply
|
Flag
0
David Reiss
David Reiss, Scientific Arts
Posted
10 years ago
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
POSTED BY:
David Reiss
Reply
|
Flag
Reply to this discussion
in reply to
Add Notebook
Community posts can be styled and formatted using the
Markdown syntax
.
Tag limit exceeded
Note: Only the first five people you tag will receive an email notification; the other tagged names will appear as links to their profiles.
Publish anyway
Cancel
Reply Preview
Attachments
Remove
Add a file to this post
Follow this discussion
or
Discard
Group Abstract
Be respectful. Review our
Community Guidelines
to understand your role and responsibilities.
Community Terms of Use
Feedback
Enable JavaScript to interact with content and submit forms on Wolfram websites.
Learn how »