I = eye(sz)
returns an array with ones on the main diagonal and zeros elsewhere. The size
vector, sz, defines size(I). For example,
eye([2,3]) returns a 2-by-3 array with ones on the main
diagonal and zeros elsewhere.
I = eye(___,typename)
also specifies the data type (class) of I for any of the
previous syntaxes. For example, eye(5,"int8") returns a
5-by-5 identity matrix consisting of 8-bit integers.
typename must be a built-in
MATLAB® numeric type. Does not invoke the static
eye method for other classes. For example,
eye(m, n, 'myclass') does not invoke
myclass.eye(m,n).
Size arguments must have a fixed size.
Usage notes and limitations:
typename must be a built-in MATLAB numeric type. Does not invoke the static
eye method for other classes. For example,
eye(m, n, 'myclass') does not invoke
myclass.eye(m,n).
The eye function
supports GPU array input with these usage notes and limitations:
You can specify typename as 'gpuArray'. If you specify
typename as 'gpuArray', the default underlying
type of the array is double.
To create a GPU array with underlying type datatype,
specify the underlying type as an additional argument before
typename. For example, I =
eye(3,datatype,'gpuArray') creates a 3-by-3 GPU identity
matrix with underlying type datatype.
You can specify the underlying type datatype as one of these
options:
'double'
'single'
'logical'
'int8'
'uint8'
'int16'
'uint16'
'int32'
'uint32'
'int64'
'uint64'
You can also specify the numeric variable p as a
gpuArray.
If you specify p as a gpuArray, the underlying type of the
returned array is the same as p.
You can specify typename as 'codistributed' or
'distributed'. If you specify typename as
'codistributed' or 'distributed', the default
underlying type of the returned array is double.
To create a distributed or codistributed array with underlying type
datatype, specify the underlying type as an
additional argument before typename. For example,
I = eye(3,datatype,'distributed') creates a 3-by-3
distributed identity matrix with underlying type
datatype.
You can specify the underlying type datatype as one of these
options:
'double'
'single'
'logical'
'int8'
'uint8'
'int16'
'uint16'
'int32'
'uint32'
'int64'
'uint64'
You can also specify p as a codistributed or distributed array.
If you specify p as a codistributed or
distributed array, the underlying type of the returned array is the same
as p.
For additional codistributed syntaxes, see eye
(codistributed) (Parallel Computing Toolbox).
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.