Iden: Difference between revisions
Jump to navigation
Jump to search
Created page with "{{Function |name=iden |desc=Computes a sparse or full identity matrix |upd=November 28, 2012 |v=1.00 |helper=1}} <tt>'''iden'''</tt> is a function that c..." |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
|name=iden | |name=iden | ||
|desc=Computes a sparse or full identity matrix | |desc=Computes a sparse or full identity matrix | ||
|cat=[[List of functions#Helper_functions|Helper functions]] | |||
|upd=November 28, 2012 | |upd=November 28, 2012 | ||
|v= | |v=0.50 | ||
|helper=1}} | |helper=1}} | ||
<tt>'''iden'''</tt> is a [[List of functions|function]] that computes the identity matrix of the desired size, which is either full or sparse. | <tt>'''iden'''</tt> is a [[List of functions|function]] that computes the identity matrix of the desired size, which is either full or sparse. | ||
| Line 16: | Line 17: | ||
==Examples== | ==Examples== | ||
Full and sparse versions of the 2-by-2 identity matrix: | Full and sparse versions of the 2-by-2 identity matrix: | ||
< | <syntaxhighlight> | ||
>> iden(2,0) | >> iden(2,0) | ||
| Line 30: | Line 31: | ||
(1,1) 1 | (1,1) 1 | ||
(2,2) 1 | (2,2) 1 | ||
</ | </syntaxhighlight> | ||
==Notes== | ==Notes== | ||
This function is only meant to simplify code within other functions. If you always want either the full or the sparse identity matrix, just use MATLAB's built-in [http://www.mathworks.com/help/matlab/ref/eye.html eye] or [http://www.mathworks.com/help/matlab/ref/speye.html speye] function. | This function is only meant to simplify code within other functions. If you always want either the full or the sparse identity matrix, just use MATLAB's built-in [http://www.mathworks.com/help/matlab/ref/eye.html eye] or [http://www.mathworks.com/help/matlab/ref/speye.html speye] function. | ||
{{SourceCode|name=iden|helper=1}} | |||
Latest revision as of 15:59, 29 September 2014
| iden | |
| Computes a sparse or full identity matrix | |
| Other toolboxes required | none |
|---|---|
| Function category | Helper functions |
| This is a helper function that only exists to aid other functions in QETLAB. If you are an end-user of QETLAB, you likely will never have a reason to use this function. |
iden is a function that computes the identity matrix of the desired size, which is either full or sparse.
Syntax
- ID = iden(DIM,SP)
Argument descriptions
- DIM: The number of rows (or equivalently, columns) that ID will have.
- SP: A flag (either 1 or 0) indicating whether ID should or should not be sparse.
Examples
Full and sparse versions of the 2-by-2 identity matrix:
>> iden(2,0)
ans =
1 0
0 1
>> iden(2,1)
ans =
(1,1) 1
(2,2) 1Notes
This function is only meant to simplify code within other functions. If you always want either the full or the sparse identity matrix, just use MATLAB's built-in eye or speye function.
Source code
Click here to view this function's source code on github.