?? randx.m
字號(hào):
function X = randX(P,n)
%RANDX Random generation of n points X that are within P's boundaries.
% X = randX(P,n)
% Generates n x d matrix X of n random d-dimensional NF locations, where
% each dimension is within the min and max EF locations of P (if m = 1,
% then each X(i,:) = P).
% P = m x d matrix of m d-dimensional EF locations
% n = number of NF locations to generate
% = 1, default
%
% Example: Two X points within x = 0..2 and y = 0..3
% P = [0 0;2 0;2 3]
% X = randX(P,2)
% Copyright (c) 1994-2006 by Michael G. Kay
% Matlog Version 9 13-Jan-2006 (http://www.ie.ncsu.edu/kay/matlog)
% Input Error Checking ****************************************************
error(nargchk(1,2,nargin));
if nargin < 2 | isempty(n), n = 1; end
if length(n(:)) ~= 1 | ~isint(n) | n < 1
error('"n" must be a positive integer.')
elseif size(P,1) < 1
error('P must have at least one point')
end
% End (Input Error Checking) **********************************************
if size(P,1) == 1
X = P(ones(1,n),:);
else
rangeP = max(P) - min(P);
X = ones(n,1)*min(P) + rand(n,size(P,2)).*rangeP(ones(n,1),:);
end
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -