【 MATLAB 】gallery 中的 uniformdata
Test matrices
gallery是一個產生測試矩陣的函式。下面講解其語法以及用法描述,資料手冊上的英文很簡單,耐心看,我就不一一翻譯了。
Syntax
[A,B,C,...] = gallery(matname,P1,P2,...)
[A,B,C,...] = gallery(matname,P1,P2,...,classname)
gallery(3)
gallery(5)
Description
[A,B,C,...] = gallery(matname,P1,P2,...)
returns the test matrices specified by matname
matname
input is the name of a matrix family selected from the table below. P1,P2,...
are input parameters required by the individual matrix family. The number of optional parameters P1,P2,...
used in the calling syntax varies from matrix to matrix. The exact calling syntaxes are detailed in the individual matrix descriptions below.[A,B,C,...] = gallery(matname,P1,P2,...)
這種語法格式,matname代表的是矩陣族的名稱,例如本文要重點突出的uniformdata,產生的矩陣將是一個元素符合均勻分佈的矩陣。P1,P2,...是各個矩陣族所需的輸入引數。它定義了需要產生的矩陣的維度等。具體要看各個具體的矩陣族。
[A,B,C,...] = gallery(matname,P1,P2,...,classname)
produces a matrix of class classname
. The classname
input must be either 'single'
'double'
(unless matname
is'integerdata'
, in which case 'int8'
, 'int16'
, 'int32'
, 'uint8'
, 'uint16'
, and 'uint32'
are also allowed). If classname
is not specified, then the class of the matrix is determined from those arguments among P1,P2,...
that do not specify dimensions or select an option. If any of these arguments is of class single
then the matrix is single
; otherwise the matrix is double
.
[A,B,C,...] = gallery(matname,P1,P2,...,classname)
這種語法格式與第一種不同在於它有一個類名,用於定義資料的類,是single還是double。如果未指定classname,則根據P1,P2,......中未指定維度或選擇選項的引數確定矩陣的類。如果這些引數中的任何一個是single類,則矩陣是single的; 否則矩陣是double的。
gallery(3)
is a badly conditioned 3-by-3 matrix and gallery(5)
is an interesting eigenvalue problem.
gallery(3)是一個條件差的3乘3矩陣,而gallery(5)是一個有趣的特徵值問題。
The gallery holds over fifty different test matrix functions useful for testing algorithms and other purposes.
該庫擁有50多種不同的測試矩陣函式,可用於測試演算法和其他目的。
uniformdata — Array of arbitrary data from standard uniform distribution
A = gallery('uniformdata',[m,n,...],j)
returns an m
-by-n
-by-... array A
. The values of A
are a random sample from the standard uniform distribution. j must be an integer value in the interval [0, 2^32-1]
. Calling gallery('uniformdata', ...)
with different values of j
will return different arrays. Repeated calls to gallery('uniformdata',...)
with the same size vector and j
inputs will always return the same array.
In any call to gallery('uniformdata', ...)
you can substitute individual inputs m
,n
,... for the size vector input [m,n,...]
. For example, gallery('uniformdata',[1,2,3,4],5)
is equivalent to gallery('uniformdata',1,2,3,4,5)
.
[A,B,...] = gallery('uniformdata',[m,n,...],j)
returns multiple m
-by-n
-by-... arrays A
, B
, ..., containing different values.
A = gallery('uniformdata',[m,n,...],j, classname)
produces a matrix of class classname
. classname
must be either 'single'
or 'double'
.
Generate the arbitrary 6-by-4 matrix of data from the uniform distribution on [0, 1] corresponding to j = 2
.
x = gallery('uniformdata', [6, 4], 2);
Generate the arbitrary 1-by-2-by-3 single array of data from the uniform distribution on [0, 1] corresponding to j = 17
.
y = gallery('uniformdata', 1, 2, 3, 17, 'single');