File:Raised-cosine filter.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 585 × 314 pixels, file size: 42 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Frequency response of raised cosine filter for different values of β.
    Date
    Source Own work
    Author Krishnavedala
    Other versions File:Raised-cosine-filter.png
    SVG development
    InfoField
     The SVG code is valid.
     This plot was created with Matplotlib.
    Source code
    InfoField

    Python code

    from numpy import *
    from matplotlib.pyplot import *
    from mpl_toolkits.axes_grid.axislines import SubplotZero
    
    def makeT(lim=1):	# Make the X-axis
    	result = linspace(-lim,lim,100)
    	return result
    
    def sinc(x):		# define normlized sinc function
    	return sin(pi*x)/(pi*x)
    	
    def raisedCos(freq,B=0.,T=1.):	# define raised cosine function
    	freq = fabs(freq)
    	if freq <= (1.-B)*0.5/T:
    		result = T
    	elif freq <= (1.+B)*0.5/T:
    		temp = freq - (1-B)*0.5/T
    		result = 0.5*T*( 1+cos(pi*temp*T/B) )
    	else:
    		result = 0
    	return result
    	
    fig = figure(figsize=(8,4))
    ax = SubplotZero(fig,111)
    fig.add_subplot(ax)
    ax.grid(True)
    ax.set_xticks([-1,-.5,0,.5,1])
    ax.set_xticklabels([r"$-\frac{1}{T}$",r"$-\frac{1}{2T}$",\
    	"0",r"$\frac{1}{2T}$",r"$\frac{1}{T}$"])
    ax.set_ylim((-.3,1.2))
    ax.set_yticklabels([])
    for direction in ["xzero","yzero"]:
    	ax.axis[direction].set_axisline_style("-&#x7C;>")
    	ax.axis[direction].set_visible(True)
    for direction in ["left","right","bottom","top"]:
    	ax.axis[direction].set_visible(False)
    
    t = makeT(1.25)
    H0,H1,H2,H3 = [],[],[],[]
    for i in t:
    	H0 = append(H0,raisedCos(i,0))
    	H1 = append(H1,raisedCos(i,0.25))
    	H2 = append(H2,raisedCos(i,0.5))
    	H3 = append(H3,raisedCos(i,1.))
    ax.plot(t,H0,label=r"$\beta=0$")
    ax.plot(t,H1,label=r"$\beta=0.25$")
    ax.plot(t,H2,label=r"$\beta=0.5$")
    ax.plot(t,H3,label=r"$\beta=1$")
    
    ax.text(1.25,0.,r"$f$")
    ax.text(0.05,1.15,r"$H(f)$")
    ax.legend()
    #fig.show()
    fig.savefig("Raised-cosine filter.svg",bbox_inches="tight",\
    	pad_inches=.15)
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following licenses:
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
    GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
    You may select the license of your choice.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current16:55, 25 June 2013Thumbnail for version as of 16:55, 25 June 2013585 × 314 (42 KB)wikimediacommons>Edgar.bonetEdited the SVG by hand, minimally, for better accuracy: - the edges of the β=0 curve were slanted, they are now vertical - the β=0.25 curve was visibly piecewise linear, it is now defined with Bézier curves that provide a better and smooth approxima...

    There are no pages that use this file.