<< Chapter < Page
  Digital signal processing - dsp     Page 10 / 27
Chapter >> Page >

Let's see some code!

I will present and explain this class in fragments. A complete listing of the class is provided in Listing 35 near the end of the module.

Beginning of the class named PlotALot01

As mentioned earlier, this class contains a main method. The main method is provided so that the class can be run as an application for self-test purposes, which is common practice in Javaprogramming. The main method also illustrates the proper use of the class.

The beginning of the class and the beginning of the main method are shown in Listing 1 .

Listing 1. Beginning of the class named PlotALot01.
public class PlotALot01{ public static void main(String[]args){ PlotALot01 plotObjectA =new PlotALot01("A",158,237,36,5,4,4); PlotALot01 plotObjectB = new PlotALot01("B");

Instantiate two plotting objects

Listing 1 instantiates two independent plotting objects. The first plotting object, referred to by plotObjectA is instantiated by calling the constructor that accepts plotting parameters. A description of each of theconstructor parameters was provided earlier . You may find it useful to compare the values shown in Listing 1 with the overall plotting parameters listed earlier to confirm how they are related.

The second plotting object, referred to by plotObjectB is instantiated by calling the constructor that accepts only the page title as aparameter and uses default values for all of the plotting parameters. You will see those default values later in the code.

Feed the plotting object titled "A"

Listing 2 contains a for loop that feeds 275 values to the plotting object titled "A". Most of the code in Listing 2 is required to set fifteen specific values to test for propertransitions as described earlier. This code is straightforward and shouldn't require further explanation.

(I was able to determine the correct locations for these values by knowing the size of the Frame, inset values for the Frame, the space betweentraces, the number of pixels dedicated to each sample, etc.)

Listing 2. Feed the plotting object titled "A".
for(int cnt = 0;cnt<275;cnt++){ if(cnt == 147){plotObjectA.feedData(0); }else if(cnt == 148){plotObjectA.feedData(0); }else if(cnt == 149){plotObjectA.feedData(25); }else if(cnt == 150){plotObjectA.feedData(-25); }else if(cnt == 151){plotObjectA.feedData(25); }else if(cnt == 152){plotObjectA.feedData(0); }else if(cnt == 153){plotObjectA.feedData(0); }else if(cnt == 26){plotObjectA.feedData(0); }else if(cnt == 27){plotObjectA.feedData(0); }else if(cnt == 28){plotObjectA.feedData(20); }else if(cnt == 29){plotObjectA.feedData(20); }else if(cnt == 30){plotObjectA.feedData(-20); }else if(cnt == 31){plotObjectA.feedData(-20); }else if(cnt == 32){plotObjectA.feedData(0); }else if(cnt == 33){plotObjectA.feedData(0); }else{plotObjectA.feedData( (Math.random() - 0.5)*25);}//end else }//end for loop

White random noise

The final statement in Listing 2 uses a random number generator to feed white random noise to the plotting object for all data values other than the fifteendata values specified in the preceding statements. You can see the random values plotted and marked by round ovals in Figure 5 .

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