help-octave
[Top][All Lists]
Advanced

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

Question on defining a digital signal x[n]


From: Oceanic
Subject: Question on defining a digital signal x[n]
Date: Wed, 8 May 2013 12:38:42 -0700 (PDT)

Hello,

Some background - I am currently teaching myself DSP and have recently taken
a Signals & Systems course.
As part of the process I am also learning how to use Octave. 

As a learning exercise I am going back to see if I can use Octave instead of
pen-and-paper to go through past examples and exercises. I will probably be
asking a lot of questions and hopefully I can can get some help. I would
like to make a preemptive apology for the noob questions 

So first question:

I have a digital signal described as follows:
x[n] = 0, when n <= -3 and when n >= 2
x[n] = 1, otherwise

I described the signal successfully (at least a window of the signal, since
it extends to +ve and -ve infinity) using the following code (contents of .m
file below):

y = ones(1,20);
x = [-10:9];
n = length(x);
for i = 1:n
  if x(i) <= -3 | x(i) >= 2
    y(i) = 0;
  end
end

stem(x,y)
axis([-15 15 -1 1.5])

My question is - Is there a more efficient way to describe this signal
(probably without having to use a for-loop)? What are the best-practices for
describing such signals?

Thank you.




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Question-on-defining-a-digital-signal-x-n-tp4652749.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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