⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genrn.m

📁 GPS TOOLBOX包含以下内容: 1、GPS相关常量和转换因子; 2、角度变换; 3、坐标系转换: &#61656 点变换; &#61656 矩阵变换; &#61656 向量变换
💻 M
字号:
%                             genrn.m
%  Scope:   This MATLAB macro generates random numbers with normal
%           (Gaussian) distribution, with mean and standard deviation 
%           specified. 
%  Usage:   x = genrn(n,xmean,xstd,iseed)   when the seed is reset to iseed 
%           x = genrn(n,xmean,xstd) 
%  Description of parameters:
%           n     - input, number of random numbers to be generated
%           xmean - input, specified mean
%           xstd  - input, specified standard deviation
%           iseed - input, initial value of the seed (optional); if it 
%                   is specified the seed is reset to iseed value
%           x     - output, random numbers with specified mean and
%                   standard deviation, vector with n elements
%  Last update: 06/27/00
%  Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.

function  x = genrn(n,xmean,xstd,iseed)
        
if ( (nargin < 3) | (nargin > 4) )
   disp('Error - GENRN.m  - check the argument list');
   disp('  ');
   return
elseif  (nargin == 4)
   rand('seed',iseed);     
end

clear x
x = zeros(n,1);

for  k = 1:n
   xsum = - 6.;
   for kk = 1:12
      xsum = rand(1) + xsum;
   end
   x(k) = xsum * xstd + xmean;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -