How to apply for Random function ?

5 次查看(过去 30 天)
Hi I work on a program in Matlab and while am compiling I saw that
"Undefined function or variable 'random'.''
what I should do thanks a lot

采纳的回答

John D'Errico
John D'Errico 2022-10-7
Random is a function in MATLAB, but it is part of the stats toolox.
help random
RANDOM Generate random arrays from a specified distribution. R = RANDOM(NAME,A) returns an array of random numbers chosen from the one-parameter probability distribution specified by NAME with parameter values A. R = RANDOM(NAME,A,B) or R = RANDOM(NAME,A,B,C) returns an array of random numbers chosen from a two- or three-parameter probability distribution with parameter values A, B (and C). The size of R is the common size of the input arguments. A scalar input functions as a constant matrix of the same size as the other inputs. R = RANDOM(NAME,A,M,N,...) or R = RANDOM(NAME,A,[M,N,...]) returns an M-by-N-by-... array of random numbers for a one-parameter distribution. Similarly, R = RANDOM(NAME,A,B,M,N,...) or R = RANDOM(NAME,A,B,[M,N,...]), and R = RANDOM(NAME,A,B,C,M,N,...) or R = RANDOM(NAME,A,B,C,[M,N,...]), return an M-by-N-by-... array of random numbers for a two- or three-parameter distribution. NAME can be: 'beta' or 'Beta', 'bino' or 'Binomial', 'burr' or 'Burr', 'chi2' or 'Chisquare', 'exp' or 'Exponential', 'ev' or 'Extreme Value', 'f' or 'F', 'gam' or 'Gamma', 'gev' or 'Generalized Extreme Value', 'gp' or 'Generalized Pareto', 'geo' or 'Geometric', 'hn' or 'Half Normal', 'hyge' or 'Hypergeometric', 'logn' or 'Lognormal', 'nbin' or 'Negative Binomial', 'ncf' or 'Noncentral F', 'nct' or 'Noncentral t', 'ncx2' or 'Noncentral Chi-square', 'norm' or 'Normal', 'poiss' or 'Poisson', 'rayl' or 'Rayleigh', 'stable'or 'Stable', 't' or 'T', 'unif' or 'Uniform', 'unid' or 'Discrete Uniform', 'wbl' or 'Weibull'. Partial matches are allowed and case is ignored. RANDOM is a generic function that accepts a distribution by name. It is faster to use a more specialized function when possible, such as RANDN or NORMRND for the normal distribution. See also CDF, ICDF, MLE, PDF. Documentation for random doc stats/prob.NormalDistribution/random Other uses of random classreg.regr.CompactGeneralizedLinearModel/random classreg.regr.CompactLinearModel/random GeneralizedLinearMixedModel/random gmdistribution/random LeastSquaresResults/random LinearMixedModel/random NLMEResults/random NonLinearModel/random piecewisedistribution/random prob.NormalDistribution/random prob.ProbabilityDistribution/random prob.UnivariateDistribution/random RepeatedMeasuresModel/random
which random
/MATLAB/toolbox/stats/stats/random.m
So either to do not have the stats toolbox, or you have an old release of MATLAB, or perhaps you are trying to use this code in Octave, which may or may not have such a function.
In the docs, I see random was introduced before R2006a, so your release is probably not that old.
  1 个评论
Taoufik Lamrani
Taoufik Lamrani 2022-10-7
Thank you very much. Yes, the main problem is that this function needs a "statistics and machine learning toolbox". Then the problem has been fixed. Thank you very much John again

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

产品


版本

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by