I have fixed the functions according to the previous suggestion (the coding of errors - see attached), but as to point that they may be a little too simplistic I would like to point out that they can be used for vectors more complicated than vectors with elements ascendingly numbered, or for creating a unit step function input vector. These could be useful maybe in converting an analog signal into a digital signal. Eg.: The vector t = [-2 -1 0 1 2 1 0 -1 -2 -1 0] as argument in function ustep(t,0) will be returned as [0 0 1 1 1 1 1 0 0 0 1]. Obviously this could be extended to such a point where the one line code suggestions would be impractical.
The other two, uramp and upulse can be used for similar purposes. On Mon, Aug 10, 2009 at 18:48, Peter Lanspeary <[email protected]>wrote: > "y=recur(a, b, x, x0, y0)" > seems to do the same job as the built-in function > "[Y, SF] = filter (B, A, X, SI, DIM)". > > upulse, uramp, ustep would be best place in the signal-processing > package, but each can be written as a "single" line of code. > > # for upulse: > t0=5; > y=zeros(10,1); y(t0)=1 > # for uramp: > y=[zeros(1,t0) 1:n-t0] > # for ustep: > y=[0:9]>=t0 > > On Sat, Aug 08, 2009 at 10:36:09PM +1000, Lyle Collins wrote: > > Attached to this email I have attached three functions which I consider > > useful in octave. I'm not sure whether they are adequately coded, but no > > worries if they are not. The general idea of each function is as follows: > > > > y = recur(a, b, x, x0, y0) : Returns a vector equal in length to that of > x, > > which is the solution to a causal discrete system equation, where x is > the > > input and y the output. 'a' and 'b' corresponds to the coefficients of y > and > > x respectively, given that the equation is of following form: > > > > y[n] = a(0)y[n-1] + a(1)y[n-2] + ... + b(0)x[n] + b(1)x[n-1] + .... > > > > x0 and y0 are the intial conditions. > > > > y = upulse(t,t0): Returns vector equal in length to t and defined as y(t) > = > > 0 if t != t0, y(t) = 1 if t = t0. > > > > y = uramp(t,t0): Returns vector equal in length to t and defined as y(t) > = 0 > > if t < t0, y(t) = t if t >= t0. > > > > y = ustep(t,t0): Returns vector equal in length to t and defined as y(t) > = 0 > > if t < t0, y(t) = 1 if t >= t0. > > > > I hope these functions are of some use. > > Lyle >
upulse.m
Description: Mathematica Notebook document
uramp.m
Description: Mathematica Notebook document
ustep.m
Description: Mathematica Notebook document
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Octave-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/octave-dev
