help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: impulse function


From: kensmith
Subject: Re: impulse function
Date: Wed, 8 Aug 2007 07:40:03 -0700
User-agent: KMail/1.9.1

you can also take advantage of the fact that true is one.

-->[1,2,3] == 2 
ans =
0 1 0



On Tuesday 07 August 2007 08:27, James Sherman Jr. wrote:
> I'm a bit confused by your code here:
>
> for n = 0:25
>        for m = 0:10
>                x(n) = (m+1)*(impulse(n-(2*m))-impulse(n-(2*m)-1));
>        endfor;
>        plot(x(n));
> endfor;
>
> First off, I think you can just implement the impulse function using
> just ==
>
> (i.e. impulse(n) = 1 if and only if n = 0, otherwise = 0)
> and secondly, you're not performing any summation in the m loop,
> you're essentially assigning x(n) the value when m = 10 (the last
> value in the loop).
>
> What I think you want is this:
> first, define imp as:
> ------
> function x = imp(n)
>
> if n == 0,
>   x = 1;
> else
>   x = 0;
> end
>
> return
> ------
>
> Then, your loop would look something like:
> ------
> x = zeros(1,26);
> index = [0:25];
>
> for n = index
>   for m = 0:10
>     x(n+1) = x(n+1) + (m+1)*(imp(n-(2*m))-imp(n-(2*m)-1));
>   end
> end
> plot(index, x);
> -------
>
> At least, I think this is what you're going for.
>
> James Sherman
>
> On 8/7/07, brito.rn <address@hidden> wrote:
> > Hi,
> >
> > I need to plot a sequence of samples of a equation that has
> > impulses.
> >
> > The sequence is here:
> > x[n] = sum((m+1)*[impulse(n-2m)-impulse(n-2m-1)]), with the sum of
> > m from 0 to 10 and n from 0 to 25.
> >
> > A simple code for that can be:
> >
> > for n = 0:25
> > for m = 0:10
> > x(n) = (m+1)*(impulse(n-(2*m))-impulse(n-(2*m)-1));
> > endfor;
> > plot(x(n));
> > endfor;
> >
> > but, the problem is: the imput impulse function format is sys type.
> > I don't have idea about how I can use this
> > sys format for my equation.
> >
> > I need help about how I can plot that sequence with impulses.
> >
> > regards,
> >
> > Brito.
> >
> >
> > _______________________________________________
> > Help-octave mailing list
> > address@hidden
> > https://www.cae.wisc.edu/mailman/listinfo/help-octave

-- 
address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]