Skip to content

MATLAB script to generate and plot basic discrete-time signals, impulse, step, ramp, exponential, signum, and sinc, with labeled axes and brief comments.

Notifications You must be signed in to change notification settings

juanre7/week3-discrete-signals-matlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Discrete-time basic signals (stem + labels)

Author: Juan Rodriguez Esteban

This repository contains a MATLAB script that generates and plots six fundamental discrete-time signals: unit impulse, unit step, unit ramp, exponential, signum, and a discrete-time sinc. Each figure uses «stem()» (not «plot()»), has labeled axes and titles, and the code includes concise inline comments explaining the key steps. The structure and presentation follow the same style as the provided README.


Included signals (short summary)

Signal Brief description Typical expression
Unit impulse Single sample at n=0 with unit amplitude δ[n]
Unit step Switches from 0 to 1 at n=0 (with u[0]=1) u[n]
Unit ramp Grows linearly from n=0 onward r[n] = n·u[n]
Exponential Geometric sequence activated at n=0 x[n] = A·αⁿ·u[n]
Signum Sign indicator over integers sgn[n] ∈ {−1,0,1}
Discrete-time sinc Band-limited kernel on integers y[n] = sin(ω_c n)/(π n), y[0]=ω_c/π

Note: The normalized continuous-time «sinc(t)=sin(πt)/(πt)» sampled at integer «t=n» collapses to zero for all «n≠0». To visualize a non-trivial sequence on the integer grid, this script uses a parameterized cutoff «ω_c» (0<ω_c≤π), i.e., «y[n]=sin(ω_c n)/(π n)» with the limiting value «y[0]=ω_c/π».


Placeholders for figures

Below are suggested paths to save or link the generated plots (replace with your actual export locations if you save figures to disk).

Signal Figure path (placeholder)
Unit impulse Unit step
Unit step Unit step
Unit ramp Unit step
Exponential Unit step
Signum Unit step
Discrete-time sinc Unit step

How to run (section by section in MATLAB)

  1. Open MATLAB and set the working folder to this project directory.

  2. Create a new script named «discrete_signals.m» and paste the provided code, or open your existing script file if you already saved it.

  3. The script is divided into sections with «%%» (Unit Impulse, Unit Step, etc.).

  4. Run one section at a time:

    • Editor → Run Section, or Ctrl+Enter (Windows/Linux), Command+Enter (macOS).
    • To run the current section and advance to the next: Ctrl+Shift+Enter (Windows/Linux), Command+Shift+Enter (macOS).
  5. Execute sections in order (impulse, step, ramp, exponential, signum, sinc). Each section opens its corresponding figure using «stem()».


Notes and tips

  • «u[0]=1» and «δ[0]=1» are implemented via logical expressions and «double(…)».

  • The ramp «r[n]=n·u[n]» is zero for «n<0» and equals «n» for «n≥0».

  • For the exponential example, pick «0<α<1» for a decaying sequence, «α>1» for growth, or «α<0» for sign-alternating behavior.

  • You can tweak:

    • index range: «n_min», «n_max»
    • exponential parameters: «A», «α»
    • sinc cutoff: «ω_c» (0<ω_c≤π)

Troubleshooting

  • If you see flat lines for the normalized sinc at integer «n», ensure you are using the parameterized version with «ω_c» as in the script notes.
  • Use «grid on» and adjust «xlim/ylim» if stems are crowded or clipped.

This README’s layout and tone were modeled after the reference README in your repo (summary, tables, placeholders, and step-by-step run instructions).

About

MATLAB script to generate and plot basic discrete-time signals, impulse, step, ramp, exponential, signum, and sinc, with labeled axes and brief comments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages