Professional Documents
Culture Documents
Py: Time Invariance Test
Py: Time Invariance Test
"""
Created on Tue Oct 07 22:45:09 2014
@author: Anish
"""
import os
os.system('cls')
import numpy as np
import matplotlib.pyplot as plt
import BasicSignals01 as BSig
N = 500
nvec11 = np.linspace(1,N,num=N)
tvec = nvec11/100
#signal 1
#x_1_t = BSig.fn_ustep(tvec,0)
x_1_t = BSig.fn_ustep(tvec,1)
y_1_t = x_1_t*cos(pi*tvec)
y_2_t = x_1_t*cos(pi*(tvec-1))
plt.plot(tvec,y_1_t,label="Output for delayed input")
plt.plot(tvec,y_2_t,label="Delayed Output")
plt.xlabel('time')
plt.ylabel('Signal')
legend(bbox_to_anchor=(.5, .9), loc=1, borderaxespad=0.)
#signal 2
#x_1_t = BSig.fn_ustep(tvec,1)
y_1_t = x_1_t*(BSig.fn_ustep(tvec,0) -BSig.fn_ustep(tvec,2))
y_2_t = x_1_t*(BSig.fn_ustep(tvec,1) -BSig.fn_ustep(tvec,3))
plt.figure(2)
plt.plot(tvec,y_1_t,'r',label="Output for delayed input")
plt.plot(tvec,y_2_t,'--',label="Delayed Output")
plt.xlabel('time')
plt.ylabel('Signal')
legend(bbox_to_anchor=(.5, .9), loc=1, borderaxespad=0.)
#signal 3
y_1_t = 0.5*(x_1_t +BSig.fn_ustep(tvec,2))
y_2_t = 0.5*(x_1_t +BSig.fn_ustep(tvec,2))
plt.figure(3)
plt.plot(tvec,y_1_t,'r',label="Output for delayed input")
plt.plot(tvec,y_2_t,'--',label="Delayed Output")
plt.xlabel('time')
plt.ylabel('Signal')
legend(bbox_to_anchor=(.5, .9), loc=1, borderaxespad=0.)
# -*- 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. example 1, time varying system
Figure 2: Example 2, time invariant system :
Figure 3: Example 3, time invariant system