Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Random Selection of Non-consecutive numbers
Replies: 1   Last Post: Nov 6, 2013 5:19 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Curious

Posts: 2,006
Registered: 12/6/04
Re: Random Selection of Non-consecutive numbers
Posted: Nov 6, 2013 5:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"nayyer " <n.saleem@student.utwente.nl> wrote in message <l5ecq1$mnt$1@newscl01ah.mathworks.com>...
> Hi,
> suppose i have a matrix of 3*2500 dimension. In the 3rd row i have the values which are not consecutive and have no order. I want to select randomly 4 values each time from 3rd row. remember that values are not consecutive.
> Thanks


% One method would be to use RANDPERM

doc randpem

% something like:
m = rand(3,2500);
% (for each time)
n = randperm(2500);
values_4 = n(1:4);
m(3,n)
% I don't have MATLAB installed on this computer.
% So, I'm not exactly sure about the syntax of the last statement.
% But it should be close.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.