Dec to bin

From QETLAB
Revision as of 19:13, 6 July 2018 by Rmmateri (talk | contribs) (Created page with "{{Function |name=dec_to_bin |desc=Converts a decimal number to a binary number in a similar way to the dec2bin function in MATLAB. |cat=List of functions#Helper_functions|He...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
dec_to_bin
Converts a decimal number to a binary number in a similar way to the dec2bin function in MATLAB.

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.

dec_to_bin 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)        1

Notes

This function is only meant to simplify code within other functions without the need to install the package dec2bin.

Source code

Click on "expand" to the right to view the MATLAB source code for this function.