Skip to main content
1-Visitor
November 13, 2014
Solved

random selection

  • November 13, 2014
  • 2 replies
  • 2207 views

Hello,

How can I randomly select an element of a matrix ?

Best answer by Fred_Kohlhepp

There is a function that returns a random number between ceertain limits. You colud use that and the ceil and floor functions to make it an integer, then use that as an index to the matrix.

2 replies

23-Emerald I
November 13, 2014

There is a function that returns a random number between ceertain limits. You colud use that and the ceil and floor functions to make it an integer, then use that as an index to the matrix.

payman1-VisitorAuthor
1-Visitor
November 13, 2014

Thank you. It works.

25-Diamond I
November 13, 2014

PAYMAN RAJAI wrote:

Hello,

How can I randomly select an element of a matrix ?

You create two integer random numbers within the valid ranges, one for row and the second for the column index.

1.png

payman1-VisitorAuthor
1-Visitor
November 13, 2014

what is the role of ORIGIN here?

25-Diamond I
November 13, 2014

Just wanted to get sure that what I post works, whatever you have ORIGIN set to.

Default value for ORIGIN is zero which is perfectly OK and I IMHO there is no reason to change that, but some people like it to be set to one.