예제 #1
0
 def __init__(self, x, h_func, t, delay_inc=.5):
     self.t_s = t[1] - t[0]
     self.t = t
     self.x = x
     self.h_func = h_func
     self.h = h_func(t)
     self.y = conv(x, self.h, t)
     self.product = np.zeros_like(self.t)
     self.t0 = np.argmin(np.abs(self.t))
     self.t0_mirror = np.argmin(np.abs(np.flip(self.t)))
     self.direction = 'stop'
     self.delay = 0
     self.delay_inc = delay_inc
예제 #2
0
def pixaxis(ax):
    ticks_loc = ax.get_xticks().tolist()
    ax.set_xticks(ax.get_xticks().tolist())
    ax.set_xticklabels(["{:.0f}".format(x / np.pi) + 'π' for x in ticks_loc])

# Questão 1a
sp = plt.subplots(1, 2)
ax_x = sp[0].axes[0]
ax_y = sp[0].axes[1]
t = np.arange(-3, 16, .01)
xtick = np.arange(-3, 16)
axis = [-1, 15, -.5, 10.2]
x = u(t)
h = 2*u(t) - u(t-3) - u(t-6)
y = conv(x, h, t)
plotit(x=t, y=x, ax=ax_x, axis=axis, xticks=xtick)
plotit(x=t, y=y, ax=ax_y, axis=axis, wait=False, save=False, xticks=xtick)

sp = plt.subplots(1, 1)
ax = sp[0].axes[0]
plotit(x=t, y=y, ax=ax, axis=[-1, 15, -1, 10], xlabel='t [s]', ylabel='y(t)', xticks=xtick, linewidth=3)

# Questão 1b
x = impulse(t)+impulse(t-1)+impulse(t-2)
y = conv(x, h, t)
sp = plt.subplots(1, 2)
ax_x = sp[0].axes[0]
ax_y = sp[0].axes[1]
plotit(x=t, y=x, ax=ax_x, axis=axis, xticks=xtick)
plotit(x=t, y=y, ax=ax_y, axis=axis, wait=False, save=False, xticks=xtick)
예제 #3
0
import matplotlib.pyplot as plt
import numpy as np
from funcoes import conv

n = np.arange(-1, 7)
x = np.zeros_like(n, dtype=float)
x[1:5] = [2, 1, 2, 1]
h = np.zeros_like(x)
h[1:4] = [1, 2, 1]
axis = [n[0], n[-1], -.1, 2.1]
y = conv(x, h, n)
y[0:-1] = y[1:]
y[-1] = 0

plt.subplot(2, 1, 1)
plt.title('Entrada e saída')
plt.stem(n, x)
plt.grid()
plt.axis(axis)
plt.subplot(2, 1, 2)
plt.stem(n, h)
plt.grid()
plt.axis(axis)

axis = [n[0], n[-1], -.1, 2.6]
plt.figure()
plt.suptitle('LIT')
plt.subplot(4, 2, 1)
x_ = np.zeros_like(x)
x_[1] = 1
plt.stem(n, x_)
예제 #4
0
from graficos import myplot as plotit
from funcoes import u, window, integrate, conv, movavgc, movavgpast, derivate, exp_u, sinc
import numpy as np
import matplotlib.pyplot as plt

t = np.arange(-1, 5, .01)
h = u(t) - u(t - 1)
x = np.cos(3 * np.pi * t) * u(t)
ya = conv(x, h, t)
x = np.cos(2 * np.pi * t) * u(t)
yb = conv(x, h, t)

plt.subplot(3, 1, 1)
plt.plot(t, h)
plt.subplot(3, 1, 2)
plt.plot(t, x)
plt.subplot(3, 1, 3)
plt.plot(t, ya)

plt.figure()
plt.subplot(2, 1, 1)
plt.plot(t, ya)
plt.grid()
plt.xlabel('t [s]')
plt.ylabel('Questão (1a)')
plt.legend(['y(t)'])
plt.subplot(2, 1, 2)
plt.plot(t, yb)
plt.grid()
plt.xlabel('t [s]')
plt.ylabel('Questão (1b)')
예제 #5
0
            x_hat = x_hat + r_(t - i * width, width) * x[t0 + i * width_s]
    return x_hat


def x_RLi(t, R, L):
    return np.exp(-t * R / L) * u(t) / L


sp = plt.subplots(1, 1)
ax_x = sp[0].axes[0]
t = np.arange(-3, 10, .01)
xtick = np.arange(-3, 10)
axis = [-1, 5, -.2, 1.6]
x = gaussian(t, 2, 1.5)
h = x_RLi(t, 2, 1)
y = conv(x, h, t)
plotit(x=t,
       y=x,
       ax=ax_x,
       axis=axis,
       xticks=xtick,
       linewidth=2,
       save=False,
       wait=True)
x_ = approx(x, t, 1)
plotit(x=t, y=x, ax=ax_x, axis=axis, xticks=xtick, linewidth=2)
plotit(x=t,
       y=x_,
       ax=ax_x,
       axis=axis,
       xticks=xtick,