Getting started guide

This commit is contained in:
2025-01-16 18:34:22 -05:00
parent a8d165aa1a
commit 1522fce3cd
16 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
% Lab 1
% Question 1 on aliasing
fs=100; % Sampling frequency [Hz]
ts=1/fs; % Sampling period [s]
n=0:1:9; % Sample indicies
x20(n+1)=cos(2*pi*20*n*ts); % x[n] with f = 20 [Hz]
x80(n+1)=cos(2*pi*80*n*ts); % x[n] with f = 80 [Hz]
subplot(211) % Start top sub plot
stem(n,x20,'linewidth',2) % Plot samples of x[n] with f = 20[Hz] for all n
subplot(212) % Start bottom sub plot
stem(n,x80,'linewidth',2) % Plot samples of x[n] with f = 80[Hz] for all n
xlabel('f = 20 and 80 Hz'); % Label the x axis

View File

@@ -0,0 +1,22 @@
import numpy as np
import matplotlib.pyplot as plt
def main():
f_s = 100 # Sample frequency [Hz]
T_s = 1/f_s # Sample period [s]
n = np.arange(10) # Samples starting at zero, up to, but not including 10
t = n*T_s # Convert from sample domain to time domain
x_20 = np.cos(2*np.pi*20*t) # Cosine signal x[n] with f = 20[Hz]
x_80 = np.cos(2*np.pi*80*t) # Cosine signal x[n] with f = 80[Hz]
plt.subplot(211) # Begin top subplot
plt.stem(n, x_20) # Plot samples of x (x_20) over sample indicies (n)
plt.subplot(212) # Begin bottom subplot
plt.stem(n, x_80) # Plot samples of x (x_80) over sample indicies (n)
plt.show() # Show the plot
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,13 @@
syms W
for k=1:24;
E(k)=single(int((sin(0.5*W)/(0.5*W))^2 ,W,0,k*pi)/pi);
end
stem(E,'linewidth',2);
hold on
EE=0.9900*ones(1,24);
plot(EE,'r','linewidth',2)
set(gca,'XTick',0:5:25)
set(gca,'XTickLabel',{'0','5\pi','10\pi','15\pi','20\pi','25\pi'})
xlabel('Angular frequency')
ylabel('Signal Energy')
axis([0 25 0 1.1])

View File

@@ -0,0 +1,2 @@
syms t
a=simplify(fourier(sin(0.5*t)/(0.5*t)))

View File

@@ -0,0 +1,12 @@
% Lab 1
% Question 4
fs=4;
ts=1/fs;
n=0:1:99;
x(n+1)=cos(2*pi*n*ts/5)+sin(4*pi*n*ts/7)+cos(16*pi*n*ts/9);
stem(n,x,'linewidth',2);
xlabel('n')
ylabel('x(n)')

View File

@@ -0,0 +1,3 @@
syms t
f=exp(-t*4)*heaviside(t);
ff=fourier(f);

View File

@@ -0,0 +1,9 @@
syms a b t
assume(a > 0)
f = exp(-a*abs(t));
ff = fourier(f);
assume(b > 0)
g = f*cos(b*t);
gg = simplify(fourier(g));