You are on page 1of 4

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

"""
Created on Mon Oct 06 20:58:11 2014

@author: Anish
"""

import os
os.system('cls')
import numpy as np
import matplotlib.pyplot as plt
import BasicSignals01 as BSig
from scipy import integrate
#a = 2
#plt.figure(1)
N = 500
nvec11 = np.linspace(1,N,num=N)
nvec2 = nvec11/100
x_t = cos(2*pi*nvec2)
#plt.figure(0)
#plt.plot(nvec2,x_t,'r')

# Signal 1
y_t = abs(x_t**2)
plt.figure(1)
plt.plot(nvec2,x_t,'r')
plt.plot(nvec2,y_t)


#signal 2
x_td1 = cos(2*pi*(nvec2-1))
y_t_2 = 0.5*(x_t + x_td1)
plt.figure(2)
plt.plot(nvec2,x_t,'r')
plt.plot(nvec2,y_t_2,'--')


#signal 3
y_t_3 = x_t*BSig.fn_ustep(nvec2,0)

plt.figure(3)
plt.plot(nvec2,x_t,'r')
plt.plot(nvec2,y_t_3,'--')

#signal 4
y_t_4 = np.zeros(np.size(x_t))
fn = lambda x : np.cos(2*pi*x)
for t in range(1,N):
y,err = integrate.quad(fn,nvec2[t]-2,nvec2[t])
y_t_4[t] = y/2.0
plt.figure(4)
plt.plot(nvec2,x_t,'r')
plt.plot(nvec2,y_t_4)

# -*- 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



(a) System1

(b) System 2

c) System 3

d) System 4
Figure 1. Input /output plots for the system 1 to 4. Input signal in red, Output signal in blue

You might also like