This document contains Python code that defines a function to generate a ramp signal. It imports modules like NumPy and Matplotlib. It then defines a function called fn_ramp that takes time values t, slope m, and offset ad as inputs. The function generates a ramp signal by multiplying the time values greater than the offset by the slope and returning the output signal y. It generates a ramp signal with 50 time points between 0-5 seconds with slope 1 and offset 0, and plots the signal.
This document contains Python code that defines a function to generate a ramp signal. It imports modules like NumPy and Matplotlib. It then defines a function called fn_ramp that takes time values t, slope m, and offset ad as inputs. The function generates a ramp signal by multiplying the time values greater than the offset by the slope and returning the output signal y. It generates a ramp signal with 50 time points between 0-5 seconds with slope 1 and offset 0, and plots the signal.
This document contains Python code that defines a function to generate a ramp signal. It imports modules like NumPy and Matplotlib. It then defines a function called fn_ramp that takes time values t, slope m, and offset ad as inputs. The function generates a ramp signal by multiplying the time values greater than the offset by the slope and returning the output signal y. It generates a ramp signal with 50 time points between 0-5 seconds with slope 1 and offset 0, and plots the signal.
Created on Sun Sep 21 16:03:38 2014 @author: Anish """ import os os.system('cls') import numpy as np import matplotlib.pyplot as plt import BasicSignals01 N = 50 nvec = np.linspace(0, 5, num=N) t = nvec m=1 ad = 0 y = BasicSignals01.fn_ramp(t,m,ad) plt.plot(t,y) plt.xlabel('time') plt.ylabel('Signal') #----------------------------------------------------------------------------------------------------------------------------------------
# -*- 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