MATFUN

Matrix Functions. Library 837. A library for the HP48 S/SX/G/GX containing a variety of matrix manipulating functions.

Table of Contents

Introduction

Documentation

Introduction

About

MATFUN is a collection of useful matrix functions for the HP48, designed to simplify working with matrices. It was concieved as a way of bringing the matrix manipulating power of Matlab to the HP48. Along the way, several additional convenience functions were added that had little to do with the original goal, but were useful nonetheless.

Installation

Download either matfun.glb or matfun.slb (depending upon what type of calculator you have). RCL the library to the stack and purge the variable it was in. Execute 0 STO and then warm start your calculator (press ON+C). If all is OK, it should be available in the library menu.

Documentation

Note on symbols

For brevity, several symbols are used to denote types native to the HP48.

%
Real number
C%
Complex number
::
Secondary - a program, denoted on the calculator by « »
[]
Array
{}
List
SYMB
Symbolic object - an equation

IARR

Incremented Array

Create an evenly incremented array from %start to %finish, optionally in steps of %increment.

Stack Diagram:
%start %increment %finish → [] %start %finish → []

ONES

Create an array of size 1 × %colums or %rows × %columns filled with %1.

Stack Diagram:
%columns → [] { %rows %colums } → []

ZEROS

Create an array of size 1 × %colums or %rows × %columns filled with %0.

Stack Diagram:
%columns → [] { %rows %colums } → []

→2D

To 2-D

Ensure a matrix is two dimensional, converting from a vector if needed.

Stack Diagram:
[1-D] → [2-D] [2-D] → [2-D]

LENGTH

Calculate the size of largest dimension of an array.

Stack Diagram:
[] → %

MTXELM

Matrix Elements

Apply a program or an equation to each element of an array.

Stack Diagram:
[] :: → []' [] SYMB → []'

FLIPLR

Flip Left Right

Exchange all columns of an array. This routine is significantly faster when the array is a row vector.

Stack Diagram:
[] → []

FLIPUD

Flip Up Down

Exchange all rows of an array. This routine is significantly faster when the array is a column vector.

Stack Diagram:
[] → []

MMIN

Matrix Minimum

Columnwise minimum of an array

Stack Diagram:
[] → %

MMAX

Matrix Maximum

Columnwise maximum of an array

Stack Diagram:
[] → %

MPLOT

Matrix Plot

Plots the columns of an array in the same manner as Matlab's plot routine. If the array is a real column vector, each element is plotted versus its index. If the array is real and not a column vector, all of the columns are plotted against the first. If the array is complex, each column is plotted individually as the imaginary part versus the real part.

Stack Diagram:
[] →

STEM

Stem Plot

Stem plots vectors. If the input is a column vector, each element is plotted versus its index. If the input has two columns the second column is plotted versus the first. If the input is a complex column vector, the imaginary part of each element is plotted versus the real.

Stack Diagram:
[] →

MFFT

Matrix Fast Fourier Transform

Fourier transform a vector. If the length of the input is a power of two, the internal FFT routine is used. Otherwise the a discrete Fourier transform is calculated from the definition (and is not particularly fast).

Stack Diagram:
[] → []'

FILTER

FIR and IIR filter. For the FIR filter, if no scalar is specified, the scale factor is assumed to be %1. If a scale factor is specified, the filter vector is normalized by it. For the IIR filter, if the first element of the denominator isn't %1, the vector is normalized by it. An initial condition vector may also be specified for the IIR filter.

Note: The IIR filter is not implemented as of MATFUN version 3.0.

Stack Diagram:
[] [filter] → [] (FIR) [] [filter] %scale → [] (FIR with scale factor) [] [numerator] [denominator] → [] (IIR) [] [numerator] [denominator] [initial condition] → [] (IIR with initial condition)

CONV

Convolution

Convolution and polynomial multiplication.

Stack Diagram:
[] [] → []

CCONV

Circular convolution

Stack Diagram:
[] [] → []

INTERP

Interpolation

Non linear interpolation. This algorithm is designed to work best with periodic signals, however it usually performs adequately with aperiodic signals.

Stack Diagram:
[] %interpolation_factor → []'

SINC

Sinc funtion

Calculates the sinc of real numbers, complex numbers, and arrays of either. The sinc function is defined as sin(x)/x.

Stack Diagram:
% → %' C% → C%' [] → []'

MPLUS

Matrix plus

Element-wise addition.

Stack Diagram:
[] [] → [] [] % → [] % [] → [] [] C% → [] C% [] → []

MMINUS

Matrix minus

Element-wise subtraction.

Stack Diagram:
[] [] → [] [] % → [] % [] → [] [] C% → [] C% [] → []

MMULT

Matrix multiplication

Element-wise multiplication.

Stack Diagram:
[] [] → [] [] % → [] % [] → [] [] C% → [] C% [] → []

MDIV

Matrix division

Element-wise division.

Stack Diagram:
[] [] → [] [] % → [] % [] → [] [] C% → [] C% [] → []

MSUM

Matrix Sum

The sum of all of the elements in an array.

Stack Diagram:
[%] → % [C%] → C%

MPROD

Matrix Product

The product of all of the elements of an array.

Stack Diagram:
[%] → % [C%] → C%

MRL

Matrix Rotate Left

Circularly rotates a vector left the number of elements specified.

Stack Diagram:
[] % → []

MRR

Matrix Rotate Right

Circularly rotates a matrix right the number of elements specified.

Stack Diagram:
[] % → []

PP0

Prepend 0

Prepends the specified number of zeros onto an array.

Stack Diagram:
[] % → []'

AP0

Append 0

Appends the specified number of zeros onto an array.

Stack Diagram:
[] % → []'

MTRN

Matrix Transpose

Performs matrix transposition, but does not take the complex conjugate of complex matrices.

Stack Diagram:
[] → []'

FFTSHIFT

Swaps the left and right halves of a vector, which after a Fourier transform moves the zero point to the middle

Stack Diagram:
[] → []'