0

How to find a random node from a matrix which contains all the nodes?

8
  • 1
    Make up your mind, are you using C# or MatLab? Commented Dec 11, 2010 at 2:53
  • i m using matlab but i was not sure about tag Commented Dec 11, 2010 at 3:00
  • Just type "matlab" and it'll be tagged [matlab]...? Commented Dec 11, 2010 at 3:03
  • i guess...can someone help me out to simulate the code..? Commented Dec 11, 2010 at 3:08
  • You're gonna have to give us a lot more details if you want help. Commented Dec 11, 2010 at 3:10

1 Answer 1

1

I will take a wild guess here and assume that you want to pick a random (i,j) entry from a MxN matrix A.

Initialize i and j using floor(M*rand(1,1)) and floor(N*rand(1,1)), respectively. Then call A(i,j).

Sign up to request clarification or add additional context in comments.

1 Comment

Here's a condensed version: random_element = A(randi(numel(A)));

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.