<< 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

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
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