<< Chapter < Page
  Digital signal processing - dsp     Page 14 / 14
Chapter >> Page >

Shifting a pulse in time introduces a linear phase angle to the complex spectrum. Conversely, introducing a linear phase angle to the complex spectrumcauses a pulse to be shifted in time.

What's next?

The next module in this series will introduce the inverse Fourier transform (as opposed to the forward Fourier transform) and will explain the reversible nature of the Fourier transform.

Complete program listing

A complete listing of the program discussed in this module is provided in Listing 6 below. Listings for other programs mentioned in the module, such as Graph03 and Graph06 , are provided in other modules. Those modules are identified in the text of this module.

Listing 6. Dsp034.java.
/* File Dsp034.java Copyright 2004, R.G.BaldwinRev 5/21/04 Computes and plots the amplitude, real, imag,and phase angle spectrum of a pulse that is read from a file named Dsp034.txt. If that filedoesn't exist in the current directory, the program uses a set of default parametersdescribing a damped sinusoidal pulse. The program also plots the pulse. When the datais plotted using the programs Graph03 or Graph06, the order of the plots from top to bottom in thedisplay are: The pulseThe amplitude spectrum The real spectrumThe imaginary spectrum The phase angle in degreesEach parameter value must be stored as characters on a separate linein the file named Dsp034.txt. The required parameters are as follows:Data length as type int Pulse length as type intSample number representing zero time as type int Low frequency bound as type doubleHigh frequency bound as type double Sample values for the pulse as type doubleThe number of sample values must match the value for the pulse length.All frequency values are specified as a double representing a fractional part of thesampling frequency. For example, a value of 0.5 specifies a frequency that is half the samplingfrequency. Here is a set of sample parameter values that canbe used to test the program. This sample data describes a triangular pulse. Don't allow blanklines at the end of the data in the file. 40011 00.0 0.50 00 4590 13590 450 00 The plotting program that is used to plot theoutput data from this program requires that the program implement GraphIntfc01. For example,the plotting program named Graph03 can be used to plot the data produced by this program. Whenit is used, the usage information is: java Graph03 Dsp034A static method named transform belonging to the class named ForwardRealToComplex01 is used toperform the actual spectral analysis. The method named transform does not implement an FFTalgorithm. Rather, it is more general than, but much slower than an FFT algorithm. (See theprogram named Dsp030 for the use of an FFT algorithm.)Tested using SDK 1.4.2 under WinXP. ************************************************/import java.util.*; import java.io.*;class Dsp034 implements GraphIntfc01{ final double pi = Math.PI;//for simplificationint dataLen;//data length int pulseLen;//length of the pulseint zeroTime;//sample that represents zero time //Low and high frequency limits for the// spectral analysis. double lowF;double highF; double[]pulse;//data describing the pulse //Following array stores input data for the// spectral analysis process. double[]data; //Following arrays receive information back// from the spectral analysis process double[]real; double[]imag; double[]angle; double[]mag; public Dsp034(){//constructor//Get the parameters from a file named // Dsp034.txt. Create and use default// parameters describing a damped sinusoidal // pulse if the file doesn't exist in the// current directory. if(new File("Dsp034.txt").exists()){getParameters(); }else{//Create default parameters dataLen = 400;//data lengthpulseLen = 100;//pulse length //Sample that represents zero time.zeroTime = 0; //Low and high frequency limits for the// spectral analysis. lowF = 0.0;highF = 0.5;//half the sampling frequency pulse = new double[pulseLen]; double scale = 240.0;for(int cnt = 0;cnt<pulseLen;cnt++){ scale = 0.94*scale;//damping scale factorpulse[cnt] =scale*Math.sin(2*pi*cnt*0.0625); }//end for loop//End default parameters }//end else//Create the data array and deposit the pulse // in it.data = new double[dataLen];for(int cnt = 0;cnt<pulse.length;cnt++){ data[cnt]= pulse[cnt];}//end for loop //Print parameter values.System.out.println( "Data length: " + dataLen);System.out.println( "Pulse length: " + pulseLen);System.out.println( "Sample for zero time: " + zeroTime);System.out.println( "Lower frequency bound: " + lowF);System.out.println( "Upper frequency bound: " + highF);System.out.println("Pulse Values"); for(int cnt = 0;cnt<pulseLen;cnt++){ System.out.println(pulse[cnt]); }//end for loop//Create array objects to receive the results // and perform the spectral analysis.mag = new double[dataLen];real = new double[dataLen];imag = new double[dataLen];angle = new double[dataLen];ForwardRealToComplex01.transform(data,real, imag,angle,mag,zeroTime,lowF,highF);}//end constructor //-------------------------------------------////This method gets processing parameters from // a file named Dsp034.txt and stores those// parameters in instance variables belonging // to the object of type Dsp034.void getParameters(){ int cnt = 0;//Temporary holding area for strings. Allow // space for a few blank lines at the end// of the data in the file. String[]data = new String[20];try{ //Open an input stream.BufferedReader inData = new BufferedReader(new FileReader("Dsp034.txt")); //Read and save the strings from each of// the lines in the file. Be careful to // avoid having blank lines at the end,// which may cause an ArrayIndexOutOfBounds // exception to be thrown.while((data[cnt] =inData.readLine()) != null){ cnt++;}//end while inData.close();}catch(IOException e){} //Move the parameter values from the// temporary holding array into the instance // variables, converting from characters to// numeric values in the process. cnt = 0;dataLen = (int)Double.parseDouble(data[cnt++]); pulseLen =(int)Double.parseDouble(data[cnt++]);zeroTime = (int)Double.parseDouble(data[cnt++]); lowF = Double.parseDouble(data[cnt++]); highF = Double.parseDouble(data[cnt++]); //Create a new array object for the pulse// and populate it from the file data. pulse = new double[pulseLen]; for(int pCnt = 0;pCnt<pulseLen;pCnt++){ pulse[pCnt]= Double.parseDouble( data[cnt++]); }//end for loopSystem.out.println( "Parameters read from file");}//end getParameters //-------------------------------------------////The following six methods are required by the // interface named GraphIntfc01. The plotting// program pulls the data values to be plotted // by calling these methods.public int getNmbr(){ //Return number of functions to process.// Must not exceed 5. return 5;}//end getNmbr //-------------------------------------------////Provide the input data for plotting. public double f1(double x){int index = (int)Math.round(x); if(index<0 || index>data.length-1){ return 0;}else{ return data[index]; }//end else}//end function //-------------------------------------------////Provide the amplitude spectral data for // plotting. Attempt to scale it so that it// will plot well in the range 0 to 180. public double f2(double x){int index = (int)Math.round(x); if(index<0 || index>mag.length-1){ return 0;}else{ return (4*dataLen/pulseLen)*mag[index]; }//end else}//end function //-------------------------------------------////Provide the real spectral data for // plotting. Attempt to scale it so that it// will plot well in the range -180 to 180. public double f3(double x){int index = (int)Math.round(x); if(index<0 || index>real.length-1){ return 0;}else{ //Scale for convenient displayreturn (4*dataLen/pulseLen)*real[index];}//end else }//end function//-------------------------------------------// //Provide the imaginary spectral data for// plotting. Attempt to scale it so that it // will plot well in the range -180 to 180.public double f4(double x){ int index = (int)Math.round(x);if(index<0 || index>imag.length-1){ return 0;}else{ //Scale for convenient displayreturn (4*dataLen/pulseLen)*imag[index];}//end else }//end function//-------------------------------------------// //Provide the phase angle data for plotting.// The angle ranges from -180 degrees to +180 // degrees. This is thing that drives the// attempt to cause the other curves to plot // well in the range -180 to+180. public double f5(double x){int index = (int)Math.round(x); if(index<0 || index>angle.length-1){ return 0;}else{ return angle[index]; }//end else}//end function //-------------------------------------------//}//end class Dsp034

Miscellaneous

This section contains a variety of miscellaneous information.

Housekeeping material
  • Module name: Java1484-Spectrum Analysis using Java, Complex Spectrum and Phase Angle
  • File: Java1484.htm
  • Published: 09/21/04

Baldwin discusses the complex spectrum and explains the relationship between the phase angle and shifts in the time domain.

Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.

In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. Ineither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please beaware that it is a copy of a module that is freely available on cnx.org and that it was made and published withoutmy prior knowledge.

Affiliation :: I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

-end-

Questions & Answers

What is inflation
Bright Reply
a general and ongoing rise in the level of prices in an economy
AI-Robot
What are the factors that affect demand for a commodity
Florence Reply
differentiate between demand and supply giving examples
Lambiv Reply
differentiated between demand and supply using examples
Lambiv
what is labour ?
Lambiv
how will I do?
Venny Reply
how is the graph works?I don't fully understand
Rezat Reply
information
Eliyee
devaluation
Eliyee
t
WARKISA
hi guys good evening to all
Lambiv
multiple choice question
Aster Reply
appreciation
Eliyee
explain perfect market
Lindiwe Reply
In economics, a perfect market refers to a theoretical construct where all participants have perfect information, goods are homogenous, there are no barriers to entry or exit, and prices are determined solely by supply and demand. It's an idealized model used for analysis,
Ezea
What is ceteris paribus?
Shukri Reply
other things being equal
AI-Robot
When MP₁ becomes negative, TP start to decline. Extuples Suppose that the short-run production function of certain cut-flower firm is given by: Q=4KL-0.6K2 - 0.112 • Where is quantity of cut flower produced, I is labour input and K is fixed capital input (K-5). Determine the average product of lab
Kelo
Extuples Suppose that the short-run production function of certain cut-flower firm is given by: Q=4KL-0.6K2 - 0.112 • Where is quantity of cut flower produced, I is labour input and K is fixed capital input (K-5). Determine the average product of labour (APL) and marginal product of labour (MPL)
Kelo
yes,thank you
Shukri
Can I ask you other question?
Shukri
what is monopoly mean?
Habtamu Reply
What is different between quantity demand and demand?
Shukri Reply
Quantity demanded refers to the specific amount of a good or service that consumers are willing and able to purchase at a give price and within a specific time period. Demand, on the other hand, is a broader concept that encompasses the entire relationship between price and quantity demanded
Ezea
ok
Shukri
how do you save a country economic situation when it's falling apart
Lilia Reply
what is the difference between economic growth and development
Fiker Reply
Economic growth as an increase in the production and consumption of goods and services within an economy.but Economic development as a broader concept that encompasses not only economic growth but also social & human well being.
Shukri
production function means
Jabir
What do you think is more important to focus on when considering inequality ?
Abdisa Reply
any question about economics?
Awais Reply
sir...I just want to ask one question... Define the term contract curve? if you are free please help me to find this answer 🙏
Asui
it is a curve that we get after connecting the pareto optimal combinations of two consumers after their mutually beneficial trade offs
Awais
thank you so much 👍 sir
Asui
In economics, the contract curve refers to the set of points in an Edgeworth box diagram where both parties involved in a trade cannot be made better off without making one of them worse off. It represents the Pareto efficient allocations of goods between two individuals or entities, where neither p
Cornelius
In economics, the contract curve refers to the set of points in an Edgeworth box diagram where both parties involved in a trade cannot be made better off without making one of them worse off. It represents the Pareto efficient allocations of goods between two individuals or entities,
Cornelius
Suppose a consumer consuming two commodities X and Y has The following utility function u=X0.4 Y0.6. If the price of the X and Y are 2 and 3 respectively and income Constraint is birr 50. A,Calculate quantities of x and y which maximize utility. B,Calculate value of Lagrange multiplier. C,Calculate quantities of X and Y consumed with a given price. D,alculate optimum level of output .
Feyisa Reply
Answer
Feyisa
c
Jabir
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing - dsp. OpenStax CNX. Jan 06, 2016 Download for free at https://legacy.cnx.org/content/col11642/1.38
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing - dsp' conversation and receive update notifications?

Ask