0% found this document useful (0 votes)
3 views3 pages

MATLAB DSP Lab Assignment Guide

The document outlines a DSP lab assignment consisting of various MATLAB programming tasks, including basic scripts for mathematical operations and signal generation. It also includes composite signal construction, short questions related to signal expressions, signal sketching, and a simulation of a spring-mass system. The assignment emphasizes practical applications of MATLAB in digital signal processing and system simulations.

Uploaded by

ec23b1133
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

MATLAB DSP Lab Assignment Guide

The document outlines a DSP lab assignment consisting of various MATLAB programming tasks, including basic scripts for mathematical operations and signal generation. It also includes composite signal construction, short questions related to signal expressions, signal sketching, and a simulation of a spring-mass system. The assignment emphasizes practical applications of MATLAB in digital signal processing and system simulations.

Uploaded by

ec23b1133
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DSP Lab Assignment - 2

1. Basic MATLAB Programs


Write MATLAB scripts for the following:

1. Sum of N integers using a for loop.

2. Factorial of a number using a while loop.

3. Check whether an input number is a prime number.

4. Simple calculator using switch-case statements (add, subtract, multiply, divide).

5. Find the maximum of two numbers using an if statement.

2. Signal Generation in MATLAB


Generate the following signals using MATLAB and plot them in both continuous and
discrete formats:

• Unit Impulse Signal

• Unit Step Signal

• Ramp Signal

• Exponential Signal

• Sinusoidal Signal

• Random Signal (both values and drawing)

• Triangular Signal (mention origin and one-sided period if non-causal)

3. Composite Signal Construction


Generate the following sequences using the basic signal functions from Q1. Compare
results using stem and plot commands.

• x(n) = 2δ(n) + 3δ(n − 1) − δ(n − 3) + 3u(n) − 2u(n − 2)

• x(n) = u(n − 1) − 2u(n − 3) + 4u(n − 10) − 3u(n − 15)

1
4. Short Questions
(a) Express the sequence
(
1, n = −3, −2, −1, 0, 1, 2, 3
x(n) =
0, otherwise

in terms of impulse and/or step functions.

(b) Express the following signal in terms of unit step functions:




4, −3 ≤ n < −1

2, −1 ≤ n < 1
x(n) =


3, 1≤n<4

0, otherwise

(c) Given the following signals, sketch the respective plots:

• x1 (n) = 5ej0.5πn , −6 ≤ n ≤ 6
• x2 (n) = 4 sin(0.25πn), −8 ≤ n ≤ 8
• x3 (n) = 6 cos(0.5πn), −6 ≤ n ≤ 6

5. Signal Sketching from Figure


Given:
x(n) = {2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2}
Plot the following transformed signals:

x1 (n) = x(n + 2), x2 (n) = x(n − 3), x3 (n) = x(−n), x4 (n) = x(−n + 2)

2
6. Spring-Mass System Simulation
Consider a spring-mass system with:

• Mass, m = 2.4 kg

• Stiffness, k = 8 N/m

• Initial displacement, x0 = 3 m

• Initial velocity, v0 = 5 m/s

Write MATLAB code to plot:

• Displacement vs Time

• Velocity vs Time

• Acceleration vs Time

You might also like