Bird
Raised Fist0
Signal Processingdata~10 mins

Time shifting a signal in Signal Processing - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Time shifting a signal
Original Signal x(t)
↓
Choose shift amount T
↓
Apply shift: y(t) = x(t - T)
↓
Shifted Signal y(t)
Start with the original signal, pick how much to shift it in time, then create a new signal shifted by that amount.
Execution Sample
Signal Processing
import numpy as np
import matplotlib.pyplot as plt

t = np.linspace(0, 1, 500)
x = np.sin(2 * np.pi * 5 * t)
T = 0.2

y = np.sin(2 * np.pi * 5 * (t - T))
This code creates a sine wave and then shifts it in time by 0.2 seconds.
Execution Table
Stept (time)x(t) = sin(2π5t)Shift Ty(t) = x(t - T)
10.0000.0000.2sin(2π5*(0-0.2)) = sin(-2π) = 0.000
20.250sin(2π5*0.25) = sin(2.5π) = -1.0000.2sin(2π5*(0.25-0.2)) = sin(2π5*0.05) = sin(0.5π) = 1.000
30.400sin(2π5*0.4) = sin(4π) = 0.0000.2sin(2π5*(0.4-0.2)) = sin(2π5*0.2) = sin(2π) = 0.000
40.600sin(2π5*0.6) = sin(6π) = 0.0000.2sin(2π5*(0.6-0.2)) = sin(2π5*0.4) = sin(4π) = 0.000
50.800sin(2π5*0.8) = sin(8π) = 0.0000.2sin(2π5*(0.8-0.2)) = sin(2π5*0.6) = sin(6π) = 0.000
61.000sin(2π5*1.0) = sin(10π) = 0.0000.2sin(2π5*(1.0-0.2)) = sin(2π5*0.8) = sin(8π) = 0.000
7End---
💡 Reached end of time vector t, no more points to shift.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6Final
tarray from 0 to 10.0000.2500.4000.6000.8001.0001.000
x(t)sin(2π5t)0.000-1.0000.0000.0000.0000.0000.000
T0.20.20.20.20.20.20.20.2
y(t)sin(2π5(t-T))0.0001.0000.0000.0000.0000.0000.000
Key Moments - 3 Insights
Why does shifting the signal by T mean using x(t - T) instead of x(t + T)?
Shifting right in time means the signal happens later, so to get the new value at time t, we look at the original signal at t - T. See execution_table rows 2 and 3 where y(t) uses x(t - T).
What happens if T is negative?
If T is negative, the signal shifts left (earlier). The formula y(t) = x(t - T) still works but with negative T it becomes y(t) = x(t + |T|). This is a time advance.
Why do some y(t) values match x(t) values at different times?
Because y(t) samples x at shifted times (t - T), so y at time t equals x at time t minus the shift. This is clear in execution_table where y(0.25) = x(0.05).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is y(t) when t = 0.25?
A0.000
B-1.000
C1.000
D0.500
💡 Hint
Check row 2 in execution_table under y(t) column.
At which step does the time t reach 1.0 and the execution stops?
AStep 6
BStep 5
CStep 7
DStep 4
💡 Hint
Look at the t column in execution_table and find when t=1.000.
If the shift T was changed to 0.5, how would y(t) at t=0.25 change compared to the current table?
Ay(0.25) would be sin(2π5*0.75) = 1.000
By(0.25) would be sin(2π5*(-0.25)) = -1.000
Cy(0.25) would be sin(2π5*0.25) = 0.000
Dy(0.25) would be sin(2π5*0.5) = 0.000
💡 Hint
Use formula y(t) = sin(2π5(t - T)) with t=0.25 and T=0.5.
Concept Snapshot
Time shifting a signal means moving it left or right on the time axis.
Use y(t) = x(t - T) to shift right by T seconds.
If T is positive, signal delays; if negative, it advances.
Shifting changes when signal features appear but not their shape.
Common in signal processing to align or delay signals.
Full Transcript
Time shifting a signal means moving the signal along the time axis. We start with the original signal x(t). We pick a shift amount T. Then we create a new signal y(t) by evaluating the original signal at t minus T, so y(t) = x(t - T). This shifts the signal to the right if T is positive, delaying it. If T is negative, the signal shifts left, advancing it. The code example creates a sine wave and shifts it by 0.2 seconds. The execution table shows values of t, original signal x(t), and shifted signal y(t). The variable tracker shows how variables change step by step. Key moments clarify why the formula uses t - T and what happens with negative shifts. The quiz tests understanding of shifted values and stopping conditions. The snapshot summarizes the concept in simple terms.

Practice

(1/5)
1. What does a positive time shift do to a signal in signal processing?
easy
A. It advances the signal, moving it backward in time.
B. It delays the signal, moving it forward in time.
C. It changes the signal's amplitude.
D. It reverses the signal in time.

Solution

  1. Step 1: Understand time shift direction

    A positive time shift means the signal is moved to a later time, which delays it.
  2. Step 2: Compare options with definition

    Only It delays the signal, moving it forward in time. correctly states that a positive shift delays the signal.
  3. Final Answer:

    It delays the signal, moving it forward in time. -> Option B
  4. Quick Check:

    Positive shift = delay [OK]
Hint: Positive shift means delay, negative means advance [OK]
Common Mistakes:
  • Confusing positive shift with advancing the signal
  • Thinking time shift changes amplitude
  • Mixing up delay and reversal
2. Which of the following is the correct Python syntax to shift a discrete signal array x by 3 units forward (delay)?
easy
A. shifted_x = np.roll(x, 3)
B. shifted_x = np.roll(x, -3)
C. shifted_x = x + 3
D. shifted_x = x.shift(3)

Solution

  1. Step 1: Understand np.roll behavior

    In numpy, np.roll(x, 3) shifts elements to the right by 3, delaying the signal.
  2. Step 2: Check other options

    shifted_x = x.shift(3) is invalid syntax for numpy arrays, np.roll(x, -3) shifts left (advances), x + 3 adds 3 to values (not time shift).
  3. Final Answer:

    shifted_x = np.roll(x, 3) -> Option A
  4. Quick Check:

    np.roll with positive shift delays signal [OK]
Hint: np.roll with positive number delays signal [OK]
Common Mistakes:
  • Using negative shift to delay signal
  • Adding number to array instead of rolling
  • Using non-existent shift method
3. Given the signal array x = [1, 2, 3, 4, 5], what is the output of np.roll(x, -2)?
medium
A. [4, 5, 1, 2, 3]
B. [2, 3, 4, 5, 1]
C. [3, 4, 5, 1, 2]
D. [5, 1, 2, 3, 4]

Solution

  1. Step 1: Understand np.roll with negative shift

    Negative shift moves elements to the left by 2 positions.
  2. Step 2: Apply shift to array

    Original: [1, 2, 3, 4, 5]
    Shift left 2: [3, 4, 5, 1, 2]
  3. Final Answer:

    [3, 4, 5, 1, 2] -> Option C
  4. Quick Check:

    Negative shift = advance signal [OK]
Hint: Negative np.roll shifts left (advances) [OK]
Common Mistakes:
  • Confusing left and right shift directions
  • Miscounting shifted elements
  • Assuming shift changes values
4. The following code attempts to shift a signal x = [10, 20, 30, 40] by 1 unit forward but produces incorrect output. What is the error?
shifted_x = np.roll(x, -1)
medium
A. The shift value should be positive to delay the signal.
B. np.roll cannot be used for shifting signals.
C. The array x must be converted to a numpy array first.
D. The shift value should be zero for no change.

Solution

  1. Step 1: Analyze shift direction

    Negative shift (-1) moves signal left (advances), not forward (delay).
  2. Step 2: Correct shift value

    To delay (shift forward), use positive shift value +1.
  3. Final Answer:

    The shift value should be positive to delay the signal. -> Option A
  4. Quick Check:

    Positive shift delays signal [OK]
Hint: Positive shift delays; negative advances [OK]
Common Mistakes:
  • Using negative shift to delay signal
  • Thinking np.roll is invalid for shifting
  • Forgetting to convert list to numpy array (not required here)
5. You have two signals sampled at the same rate: s1 = [0, 1, 2, 3, 4] and s2 = [3, 4, 0, 1, 2]. Which time shift applied to s1 aligns it best with s2?
hard
A. Shift s1 by +3 units (delay by 3)
B. Shift s1 by +1 units (delay by 1)
C. Shift s1 by -2 units (advance by 2)
D. Shift s1 by -3 units (advance by 3)

Solution

  1. Step 1: Compare signals visually

    s1 = [0, 1, 2, 3, 4], s2 = [3, 4, 0, 1, 2]. s2 matches s1 advanced (shifted left) by 3.
  2. Step 2: Verify with np.roll

    np.roll(s1, -3) = [3, 4, 0, 1, 2] matches s2 exactly. np.roll(s1, 1) = [4, 0, 1, 2, 3], np.roll(s1, -2) = [2, 3, 4, 0, 1], np.roll(s1, 3) = [2, 3, 4, 0, 1] do not match.
  3. Final Answer:

    Shift s1 by -3 units (advance by 3) -> Option D
  4. Quick Check:

    np.roll(s1, -3) == s2 [OK]
Hint: Match s2 by rolling s1 left/right to align [OK]
Common Mistakes:
  • Choosing wrong shift direction
  • Not checking exact element alignment
  • Confusing delay with advance
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard