Matlab plotting discrete time signals

Click For Summary
SUMMARY

This discussion focuses on plotting discrete time signals in MATLAB, specifically the signal defined as x[n] = { 1 for 0<=n<=4, 0 elsewhere. The user initially attempted to create the signal using x = [1 1 1 1], which is incorrect as it does not define 'n'. The correct approach involves defining a range for 'n' and initializing a zero vector, followed by setting the first five elements to 1. The final plotting is accomplished using the 'stem' function for discrete data visualization.

PREREQUISITES
  • Basic understanding of MATLAB syntax and functions
  • Familiarity with discrete time signals
  • Knowledge of vector initialization in MATLAB
  • Experience with MATLAB plotting functions, specifically 'stem'
NEXT STEPS
  • Learn MATLAB vector operations and indexing
  • Explore MATLAB's 'stem' function for advanced plotting techniques
  • Study discrete time signal representation in MATLAB
  • Investigate MATLAB's signal processing toolbox for additional functions
USEFUL FOR

Students, engineers, and researchers working with signal processing in MATLAB, particularly those interested in visualizing discrete time signals.

Larrytsai
Messages
222
Reaction score
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'.
 
Physics news on Phys.org
% 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
 
Thank you so much this is exactly what I was looking for!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K