📄 setseed.m
字号:
function oseed = setseed(val1, val2) % sets the seed to random generators% DESCRIPTION oseed = setseed(val1, val2)% The seed is set to the MATLAB 4 generator % and the old seed is delivered as vector output. % If no input the seed is not altered.% INPUT % val1 -- A seed value, any real value.% val2 -- Same as val1, used to set the seed for randn. % OUTPUT% oseed -- The current seeds for rand and randn as a vector.% TRY% oseed = setseed(3),% oseed = setseed(3,4), % oseed = setseed% SEE ALSO% rand('seed', randn('seed')% by Magnus Almgren 990301oseed = [rand('seed') randn('seed')]; % get the old seedif nargin == 0 % set the new oneelseif nargin==1 if length(val1)>1 rand('seed', val1(1)); % one input with two elements randn('seed', val1(2)); else rand('seed', val1); % one input with one elements randn('seed', val1); endelse rand('seed', val1(1)); % two inputs randn('seed', val2(1));end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -