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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.