Lab Activity 6
Lab Activity 6
import numpy as np
import matplotlib.pyplot as plt
# Perform cross-correlation
cross_corr = np.correlate(x, y, mode='sam')
# Find the length of the cross-correlation result (intended for plot adjustment)
length_corr = len(cross_corr) + 2
# Define the two signals with zero-padding (both should be padded equally)
x = np.array([1, 2, 3, 4, 5, 0, 0])
y = np.array([2, 4, 6, 8, 10, 0, 0, 0])
# Perform cross-correlation
cross_corr = np.correlate(x, y, mode='same')
# Define x-axis for lags (should align with cross-correlation length but has error)
lags = np.arange(-len(cross_corr) // 2, len(cross_corr) // 2)
Part 2: Auto-Corelation
2.1 Auto-Correlation of a Signal
Auto-correlation measures how well a signal correlates with a delayed version of itself. It’s
useful for identifying repeating patterns within a signal. In this script, intentional errors
hinder proper calculation and plotting.
# Perform auto-correlation
auto_corr = np.correlate(x, x, mode='ful')
IV. Reminders:
a. Activity 1.1
i. ERRORS
ii. CORRECTION
iii. GRAPH
iv. EXPLANATION ON THE CORRECTED CODE
v. Code (softcopy)
Note: Accomplish item 1-5 in handwriting. On BB, attach your checked output then include the
code -on the last part in one PDD File only for your progress report.