0% found this document useful (0 votes)
748 views2 pages

MATLAB Ramp Function Implementation

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.

Uploaded by

anish25
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
748 views2 pages

MATLAB Ramp Function Implementation

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.

Uploaded by

anish25
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Code Explanation
  • Graph Representation

# Written in Python(x,y)

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


Created on Sun Sep 21 16:03:38 2014
@author: Anish
"""
import os
[Link]('cls')
import numpy as np
import [Link] as plt
import BasicSignals01
N = 50
nvec = [Link](0, 5, num=N)
t = nvec
m=1
ad = 0
y = BasicSignals01.fn_ramp(t,m,ad)
[Link](t,y)
[Link]('time')
[Link]('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 = [Link](N)
for i in range(1,N):
if t[i] >= -ad:
y[i] = m*(t[i]+ad)
return y

#----------------------------------------------------------------------------------------------------------------------------------------

Figure: Basic ramp signal

# Written in Python(x,y)  
# -*- coding: utf-8 -*- 
""" 
Created on Sun Sep 21 16:03:38 2014 
 
@author: Anish 
""" 
 
import
 
Figure: Basic ramp signal

You might also like