matlab randint函数数后面参数什么意思randint(1,N,M)

[转载]Matlab中的几个随机函数-randperm,sort,rand,randint
Matlab自带函数randperm(n)产生1到n的整数的无重复的随机排列,利用它就可以得到无重复的随机数。
function p =
randperm(n);
%RANDPERM Random
permutation.
% RANDPERM(n) is a random
permutation of the integers from 1 to n.
% For example, RANDPERM(6) might
be [2 4 5 6 1 3].
% Note that RANDPERM calls RAND
and therefore changes RAND's state. %
% See also PERMUTE. % Copyright
The MathWorks, Inc.
% $Revision: 5.10 $ $Date:
00:26:14 $
[ignore,p] =
sort(rand(1,n));
1. rand(1,
n)产生1行n列的0-1之内的随机数矩阵。
sort()把这个矩阵排序,返回的ignore是排序后的序列,p是排序后的序列的各数原来的索引,这个索引肯定是随机的,而且是在1到n间无重复的整数。
附:《Matlab中的几个随机函数》
rand(n):生成0到1之间的n阶随机数方阵
rand(m,n):生成0到1之间的m&n的随机数矩阵
randint(m,n,[1
N]):生成m&n的在1到N之间的随机整数矩阵,其效果与randint(m,n,N+1)相同。
randint(3,4,[1 10])
&& randint(3,4,11)
randperm(n):产生一个1到n的随机顺序。
&& randperm(10)
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。1694人阅读
randint(n,m)产生的是一个n*m维的矩阵,矩阵的元素或者是0或者是1,是随机的。
如果想产生一个范围的数,可以设置一个区间,如randint(2,3,[1 6]),就是产生一个2*3随机矩阵,这个矩阵的元素是区间[1 6]的随机数。
randint(3,3)
>> randint(3,3)
>> randint(3,3,[2 3 ])
>> randint(3,3,[2 3 ])
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1036040次
积分:14412
积分:14412
排名:第256名
原创:365篇
转载:251篇
评论:250条
(1)(1)(2)(1)(7)(4)(3)(14)(3)(8)(2)(2)(11)(25)(29)(1)(10)(26)(153)(85)(15)(15)(13)(1)(1)(11)(9)(8)(4)(59)(48)(8)(14)(24)(3)(2)(2)mk=a(randint(1)+1)*sqrt(2)/2+i*a(randint(1)+1)*sqrt(2)/2 请教MATLAB大神,这个语句的意思是什么?_百度知道
mk=a(randint(1)+1)*sqrt(2)/2+i*a(randint(1)+1)*sqrt(2)/2 请教MATLAB大神,这个语句的意思是什么?
提问者采纳
利用 a 数组的第一、二个元素;mk=a(randint(1)+1)*sqrt(2)/2+i*a(randint(1)+1)*sqrt(2)&#47,随机生成一个复数或零% randint(1) 随机生成 0 or 1a = [1 2]
如果a=[-1,1],生成的mk信号应该是什么形式?
% mk 有下面4种结果:0.7071 + 0.7071i0.7071 - 0.7071i-0.7071 + 0.7071i-0.7071 - 0.7071i
提问者评价
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁matlab中的randint.m文件求共享_百度知道
matlab中的randint.m文件求共享
我的matlab中没有randint这个函数文件,有的话发给我吧
提问者采纳
);n&#47, and initializes the state of that%
generator using the value of STATE:,STATE) causes RAND to use the generator%
determined by the 'n = [];0&% --- randint(m:NonPositiveMatrixDims'0&% --- randint(m;
error(message(&#39.
endend% Make sure IRANGE occur with equal probability,[-2 2])%%
See also RAND;n&#39.%%
OUT = RANDINT(M,3; occur wi 0
range = [range+1; 2
error(message(&#39,IRANGE) generates an M-by-N matricommdeprecated&#92:randint:InvalidArg'n'0&struct&#39,1) * size(range.1:nargin
if(i&Please use RANDI instead:40 $warnobsolete(if isempty(m)
% --- If the parameter list does not match one
n= varargin{2}:randint.%
The MathW));));% --- Placeholder for &#39, n) * (distance+1)),&#39.out = ones(m.%
V% Basic function setup.if len_range &lt: If IRANGE in/
state = varargin{4}, 1], then the output integer%
range is [0;n&#39.6, range-1];elseif len_range &gt,n/% --- Identify parameter signatures and assign values to variablesswitch sigStr
% --- randint
case 'elseif (~isfinite(m)) || (~isfinite(n))
error(message('out = out +state'% Typical error-checking.3 $ $D
% --- randint(m)
case ' 0
range = [0, IRANGE-1];comm&#92.
If IRANGE is a negative integer:35, Inc:InvalidIrange&#39:InvalidMatrixDims')); 2
if range &end% If the IRANGE is send, 0].error(nargchk(0: If IRANGE is a two-)):randint:randint, n)case &#39, RANDERR:%
r1 = randint(2;
range = varargin{3};n/', then the output%
integer range is [IRANGE(1).if ~isempty(state)
rand(&#39,N;state = [].%%
OUT = RANDINT(M,%
then the output integer range is [IRANGE+1.mfunction out = randint(varargin)%%%WARNING,2)+1) = &#39,3,3;
end:NonIntegerMatrixDims&#39, IRANGE(2)],n)*range(1);10&#47:));comm: This is an obsolete function and may be r and &% Set the initial state if specified,3)
r2 = randint(2.%
OUT = RANDINT generates a &% --- randint(m;comm,-4)
r4 = randint(2;))% 安装目录&#92: 1,N) generates an M-by-N matrix of r method.%
m= varargin{1};, &#39, state);endlen_range = size(range, RANDSRC;
% Special case of zero range.%
Please use RANDI instead: 2011&#47,toolbox\
m= varargin{1}.distance = range(2) - range(1):/ 0) || (n &
m= varargin{1};range = []; wi
m= varargin{1},IRANGE.r = floor(rand(m;n&#47.
error(message(&#39.sigStr = '1&quot:NonIntIrange'elseif (m &lt, 0].%%%RANDINT Generate matrix of uniformly distrib% [EOF] randint,2),N,
= varargin{2}.%
&% --- Identify string and numeric argumentsfor i=1, state)case 'end% Generatn' or &quot.if all(length(m) &gt, range)case &#39.%%
IRANGE can be either a scalar or a two-element vector:InvalidSyntax'
range = [0:));
elseif range &gt:%
Scalar ,4;% Offset the numbers to 1) || all(length(n) &1&quot.%
$R));)).%%
Eendif isempty(range)
range = [0; 1)
error(message('% Calculate the range the distance for the ran; 0)
error(message(&#39.'n'
n= varargin{2}.range = sort(range);endif isempty(n)
range = varargin{3};m = [],state&#39, 0]:NonFiniteMatrixDims&#39,2)+1) = &#39.%%
OUT = RANDINT(M) generates an M-by-M matrix of relseif (floor(m) ~= m) || (floor(n) ~= n) || (~isreal(m)) || (~isreal(n))
error(message('1)
sigStr(size(sigStr.%%
OUT = RANDINT(M; and &elseif max(max(floor(range) ~= range)) || (~isreal(range)) || all(~isfinite(range))
error(message('1&'01 20;
% --- Assign the string and numeric flags
if(isnumeric(varargin{i}))
sigStr(size(sigStr,4)%
r3 = randint(2
提问者评价
其他类似问题
matlab的相关知识
您可能关注的推广
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁[学习笔记]MATLAB&R2011a中randint与randi
在MATLAB R2011a中若使用randint(m,n,[IMIN
IMAX])生成IMIN~IMAX区间m*n维互不相同的整数矩阵,会出现错误:
Function RANDINT is deprecated. Use RANDI instead.
而randi函数格式与randint略有不同,为randi([IMIN IMAX],m,n),但是功能相同。
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。}

我要回帖

更多关于 matlab randint函数 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信