matlab randi 函数,急求MATLAB的randi函数源代码,我的7.1没有,谢谢谢谢

满意答案

00e27ab806e4881f8254fe7ae8741834.png

cowboy823

2014.03.08

00e27ab806e4881f8254fe7ae8741834.png

采纳率:57%    等级:12

已帮助:6451人

%RANDI Pseudorandom integers from a uniform discrete distribution.

% R = RANDI(IMAX,N) returns an N-by-N matrix containing pseudorandom

% integer values drawn from the discrete uniform distribution on 1:IMAX.

% RANDI(IMAX,M,N) or RANDI(IMAX,[M,N]) returns an M-by-N matrix.

% RANDI(IMAX,M,N,P,...) or RANDI(IMAX,[M,N,P,...]) returns an

% M-by-N-by-P-by-... array. RANDI(IMAX) returns a scalar.

% RANDI(IMAX,SIZE(A)) returns an array the same size as A.

%

% R = RANDI([IMIN,IMAX],...) returns an array containing integer

% values drawn from the discrete uniform distribution on IMIN:IMAX.

%

% Note: The size inputs M, N, P, ... should be nonnegative integers.

% Negative integers are treated as 0.

%

% R = RANDI(..., CLASSNAME) returns an array of integer values of class

% CLASSNAME.

%

% The sequence of numbers produced by RANDI is determined by the internal

% state of the uniform pseudorandom number generator that underlies RAND,

% RANDI, and RANDN. RANDI uses one uniform value from that default

% stream to generate each integer value. Control the default stream using

% its properties and methods. See RANDSTREAM for details about the

% default stream.

%

% Resetting the default stream to the same fixed state allows computations

% to be repeated. Setting the stream to different states leads to unique

% computations, however, it does not improve any statistical properties.

% Since MATLAB uses the same state each time it starts up, RAND, RANDN, and

% RANDI will generate the same sequence of numbers in each session unless

% the state is changed.

%

% Examples:

%

% Generate integer values from the uniform distribution on the set 1:10.

% r = randi(10,100,1);

%

% Generate an integer array of integers drawn uniformly from 1:10.

% r = randi(10,100,1,'uint32');

%

% Generate integer values drawn uniformly from -10:10.

% r = randi([-10 10],100,1);

%

% Save the current state of the default stream, generate 5 integer

% values, restore the state, and repeat the sequence.

% defaultStream = RandStream.getDefaultStream;

% savedState = defaultStream.State;

% i1 = randi(10,1,5)

% defaultStream.State = savedState;

% i2 = randi(10,1,5) % contains exactly the same values as i1

%

% Replace the default stream with a stream whose seed is based on CLOCK, so

% RANDI will return different values in different MATLAB sessions. NOTE: It

% is usually not desirable to do this more than once per MATLAB session.

% RandStream.setDefaultStream(RandStream('mt19937ar','seed',sum(100*clock)));

% randi(10,1,5)

%

% See also RAND, RANDN, RANDSTREAM, RANDSTREAM/RANDI, RANDSTREAM.GETDEFAULTSTREAM.

% Copyright 2008 The MathWorks, Inc.

% $Revision: 1.1.6.2 $ $Date: 2008/09/13 06:57:04 $

% Built-in function.

05分享举报

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值