S = speye(sz) returns a
matrix with ones on the main diagonal and zeros elsewhere. The size vector
sz defines size(S). For example, speye([2
3]) returns a 2-by-3 matrix.
S = speye(___,typename)
returns a sparse matrix of the specified data type. Specify the data type in addition to
any of the input argument combinations in previous syntaxes. (since R2025a)
Create a 1000-by-1000 square sparse identity matrix and view the sparsity pattern.
I = speye(1000);
spy(I)
The result is the same as sparse(eye(1000)), but this latter version requires temporary storage for the full representation before it is converted to sparse storage.
The speye function
supports GPU array input with these usage notes and limitations:
To run this function on a GPU and obtain a gpuArray output, use
any of these syntaxes:
S = gpuArray.speye.
S = gpuArray.speye(n).
S = gpuArray.speye(n,m).
S = gpuArray.speye(sz).
S =
gpuArray.speye(___,typename), where typename
specifies the data type in addition to the input argument combinations in any of
the previous syntaxes. (since R2025a)
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.