|Pads an array with zeroes in a similar way to padarray 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.|
pad_array is a function that takes an array and either prepends or postpends a number of zeroes specified by the function call.
- BIN = pad_array(ARR, PAD_NUM, DIR)
- ARR: The array which will have zeroes padded onto it.
- PAD_NUM: The number of zeroes to either prepend or postpend onto ARR. This must be a non-negative integer.
- DIR: An integer specifying whether to prepend or postpend the zeroes onto ARR. 0 means to prepend, 1 means to postpend, and any other number will throw an error.
A basic example of how pad_array works.
This function is only meant to simplify code within other functions without the need to install the image processing package of MATLAB or Octave-Forge. Note that this function only pads with zeroes. If other numbers are required, please use the `padarray' function within the image processing toolbox of MATLAB or Octave-Forge.
Click on "expand" to the right to view the MATLAB source code for this function.
%% IDEN Computes a sparse or full identity matrix
% This function has two required arguments:
% DIM: the number of rows (or columns) of the identity matrix
% SP: a flag (1 or 0)
% ID = iden(DIM,SP) returns the DIM-by-DIM identity matrix. If SP = 0
% then ID will be full. If SP = 1 then ID will be sparse.
% Only use this function within other functions to easily get the correct
% identity matrix. If you always want either the full or the sparse
% identity matrix, just use MATLAB's built-in eye or speye function.
% URL: http://www.qetlab.com/iden
% requires: nothing
% author: Nathaniel Johnston (email@example.com)
% package: QETLAB
% last updated: November 28, 2012
function id = iden(dim,sp)
id = speye(dim);
id = eye(dim);