Matlab plotting discrete time signals

  • Thread starter Larrytsai
  • Start date
  • #1
228
0
hey I was just wondering if anyone can teach me how to graph a signal like this


x[n] = { 1 for 0<=n<=4
{ 0 elsewhere

im not sure how to do this, what I have tried is

x = [1 1 1 1]

but this is not a function of 'n'.
 

Answers and Replies

  • #2
olivermsun
Science Advisor
1,244
118
% You could do something like this:

n = [0:10]; % or whatever you want your limits to be
x = zeros(1,length(n));
x(1:5) = 1

stem(n, x); % fancy plotting for discrete data
 
  • #3
228
0
Thank you so much this is exactly what I was looking for!
 

Related Threads on Matlab plotting discrete time signals

Replies
3
Views
2K
Replies
0
Views
6K
  • Last Post
Replies
1
Views
8K
Replies
3
Views
6K
  • Last Post
Replies
0
Views
2K
Replies
1
Views
1K
Replies
9
Views
750
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
1
Views
859
Top