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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.