<< Chapter < Page
  Digital signal processing - dsp     Page 13 / 24
Chapter >> Page >

Will discuss the code in fragments

As usual, I will discuss the code in fragments. A complete listing of the program is presented in Listing 19 near the end of the module. Because of the similarity of Dsp028 with Dsp029 discussed earlier, the fragments for Dsp028 will be much larger and will be explained in much less detail.

Beginning of the class named Dsp028

The class definition begins in Listing 8 . For reasons that you already understand, this class implements the interface named GraphIntfc01.

Listing 8. Beginning of the class named Dsp028.
class Dsp028 implements GraphIntfc01{ final double pi = Math.PI;//for simplification//Begin default parameters int len = 400;//data length//Sample that represents zero time. int zeroTime = 0;//Low and high frequency limits for the // spectral analysis.double lowF = 0.0; double highF = 1.0;int numberSpectra = 5; //Frequencies of the sinusoidsdouble[] freq = {0.1,0.2,0.3,0.4,0.5};//Amplitudes of the sinusoids double[]amp = {60,70,80,90,100}; //End default parameters

The code in Listing 8 defines a set of default parameter values that are used in the event that a file named Dsp028.txt does not exist in the current directory.

Declare array variables

The code in Listing 9 declares several array variables that will be used to point to array objects whose purposes are explained in the comments.

Listing 9. Declare array variables.
//Following arrays will contain data that is // input to the spectral analysis process.double[] data1;double[] data2;double[] data3;double[] data4;double[] data5;//Following arrays receive information back // from the spectral analysis that is not used// in this program. double[]real; double[]imag; double[]angle; //Following arrays receive the magnitude// spectral information back from the spectral // analysis process.double[] magnitude1;double[] magnitude2;double[] magnitude3;double[] magnitude4;double[] magnitude5;

The constructor

The constructor for the class begins in Listing 10 . The constructor begins by getting the parameters from a file named Dsp028.txt . If that file doesn't exist in the current directory, default parameters are used.

Listing 10. Beginning of the constructor.
public Dsp028(){//constructor if(new File("Dsp028.txt").exists()){getParameters(); }//end if

Always processes five sinusoids

For simplicity, this program always processes five sinusoids, even if fewer than five were requested as the input parameter for numberSpectra . In that case, the extra sinusoids are processed using default values and simplyignored when the results are plotted.

Create the raw sinusoidal data

The code in Listing 11 instantiates array objects and creates the sinusoidal data upon which spectral analysis will be performed.

Listing 11. Create the raw sinusoidal data.
//First create empty array objects. double[]data1 = new double[len];double[] data2 = new double[len]; double[]data3 = new double[len];double[] data4 = new double[len]; double[]data5 = new double[len];//Now populate the array objects for(int n = 0;n<len;n++){ data1[n]= amp[0]*Math.cos(2*pi*n*freq[0]); data2[n]= amp[1]*Math.cos(2*pi*n*freq[1]); data3[n]= amp[2]*Math.cos(2*pi*n*freq[2]); data4[n]= amp[3]*Math.cos(2*pi*n*freq[3]); data5[n]= amp[4]*Math.cos(2*pi*n*freq[4]); }//end for loop

Questions & Answers

what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
how nano science is used for hydrophobicity
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
what is differents between GO and RGO?
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
characteristics of micro business
for teaching engĺish at school how nano technology help us
How can I make nanorobot?
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
how can I make nanorobot?
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
what is the actual application of fullerenes nowadays?
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

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?