You are on page 1of 4

# -*- coding: utf-8 -*-

"""
Created on Wed Oct 08 22:15:10 2014

@author: Anish
"""


import os
os.system('cls')
import numpy as np
import matplotlib.pyplot as plt
import BasicSignals01 as BSig

N = 200
nvec11 = np.linspace(-N,N,num=N)
xtvec_1 = nvec11/10

y_t = 100*xtvec_1
for t in range(1,N):
if xtvec_1[t] > 10:
y_t[t] = 1000
if xtvec_1[t] < -10:
y_t[t] = -1000
plt.figure(1)
plt.plot(xtvec_1,y_t,'r',linewidth=2.0)
plt.xlim(-21,21)
plt.ylim(-1050,1050)
plt.xlabel('input')
plt.ylabel('output')

N = 400
nvec11 = np.linspace(-N,N,num=N)
tv = nvec11/35
xt2 = 20*cos(2*pi*tv)*BSig.fn_ustep(tv,0)

plt.figure(2)
plt.plot(tv,xt2,'s-b')
plt.xlabel('time')
plt.ylabel('input')


y_t2 = 100*xt2
for t in range(1,N):
if xt2[t] > 10:
y_t2[t] = 1000
if xt2[t] < -10:
y_t2[t] = -1000


plt.figure(3)
plt.plot(tv,y_t2,'s-r',linewidth=2.0)
plt.xlim(-21,21)
plt.ylim(-1050,1050)
plt.xlabel('time')
plt.ylabel('output')
plt.figure(4)
plt.plot(xt2,y_t2,'o')
#plt.plot(tv,y_t,'r',linewidth=2.0)
plt.xlim(-21,21)
plt.ylim(-1050,1050)
plt.xlabel('input')
plt.ylabel('output')


# -*- coding: utf-8 -*-
"""
Created on Sun Sep 21 15:44:07 2014

@author: Anish
"""
import numpy as np

def fn_ramp(t,m,ad):
N = len(t)
y = np.zeros(N)
for i in range(1,N):
if t[i] >= -ad:
y[i] = m*(t[i]+ad)
return y
def fn_ustep(t,ad):
N = len(t)
y = np.zeros(N)
for i in range(1,N):
if t[i] >= -ad:
y[i] = 1
return y




Figure 1: Input /output relation for any input

Figure 2. Cosine Input for t> 0


Figure 3: Output for cosine input after t > 0

Figure 4: Input /output relation for a specific input (cosine)

You might also like