From help-request at octave dot org Sun Feb 6 16:34:55 2005 Subject: Re: unit sample sequence ->step From: Quentin Spencer To: NZG CC: help at octave dot org Date: Sun, 06 Feb 2005 16:37:14 -0600 I would implement that like this (assuming, like you do, that the input vector t contains time indices): u=zeros(size(t)); u(find(t>=0))=1; NZG wrote: >It does, my bad, I meant the unit step. > >function retval = u(t) >for i = 1:length(t) >if (t(i) >= 0) >retval(i)=1; >else >retval(i)=0; >endif >endfor >endfunction > > >NZG. > >On Friday 04 February 2005 12:39 pm, you wrote: > > >>On Thu, Feb 03, 2005 at 09:21:32PM -0600, NZG wrote: >> >> >>>Is there an easy way to generate vector/matrix representing the unit >>>sample sequence in Octave? >>> >>>thx, >>>NZG. >>> >>> >>If "unit sample sequence" means the same as at >> >> http://www.swarthmore.edu/NatSci/echeeve1/Class/e71/E71L1/E71L1.html >> >>then it's just u=zeros(1,n); u(d)=1. For example: >> >>octave> u=zeros (1, 4); u(2)=1 >>u = >> >> 0 1 0 0 >> >> >>Geordie McBain >>www.aeromech.usyd.edu.au/~mcbain >> >> > > > >------------------------------------------------------------- >Octave is freely available under the terms of the GNU GPL. > >Octave's home on the web: http://www.octave.org >How to fund new projects: http://www.octave.org/funding.html >Subscription information: http://www.octave.org/archive.html >------------------------------------------------------------- > > > > ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------