Code covered by the BSD License  

Highlights from
Random Element

4.5

4.5 | 2 ratings Rate this file 15 Downloads (last 30 days) File Size: 1.4 KB File ID: #6644

Random Element

by Skynet

 

28 Dec 2004 (Updated 25 Apr 2005)

Returns elements randomly selected from any matrix.

| Watch this File

File Information
Description

RANDELEMENT(ARRAY,N) returns a row of N elements, selected at random (and with replacement) from ARRAY.

[There probably is some toolbox function that does something very similar.]

EXAMPLES:

randelement([0:9],5)
may return [4 8 8 5 2]

randelement({'a' 'b' 'c' 'd' 'e' 'f'},2)
may return {'f' 'd'}

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
12 Aug 2005 Sameer Aidoor  
31 Oct 2006 abhay krishna

hi there very useful,still searching for the tool box fundtion similiar to randelement,also for my purpose i am trying to reverse engineer original matrix after change in these random elements.

11 Feb 2009 Adam Chapman

Nice and simple, does the job perfectly. Thanks!

13 Jan 2011 Jennifer

randsample(population,k) in the Statistics Toolbox does this WITHOUT replacement.

Please login to add a comment or rating.
Updates
20 Apr 2005

Fixed error in Description and Comments.

25 Apr 2005

Made minor update to description and comments.

Tag Activity for this File
Tag Applied By Date/Time
matrices Skynet 22 Oct 2008 07:38:49
rand Skynet 22 Oct 2008 07:38:49
random Skynet 22 Oct 2008 07:38:49
element Skynet 22 Oct 2008 07:38:49
matrix manipulation Skynet 22 Oct 2008 07:38:49
utilities Skynet 22 Oct 2008 07:38:49

Contact us at files@mathworks.com