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

Some data is not random

Fifteen of the data values for each data set are not random for the same reasons discussed earlier. Figure 3 shows how these specific values confirm proper transition from one trace to the next on the same page and confirm theproper transition from one page to the next.

Modified constructor code

The first code that I will highlight as being different from the code in the class named PlotALot02 is shown in Listing 33 . This code appears in the modified constructor for the PlotALot03 class.

Listing 33. Modified constructor code.
if((tracesPerPage == 0) || (tracesPerPage%2 != 0) ){System.out.println("Terminating program"); System.exit(0);}//end if samplesPerPage = canvasWidth * tracesPerPage/(sampSpacing + 1)/2;

The if statement in Listing 33 confirms that the number of traces per page is evenly divisible by two. If not, the program terminates.

The last statement in Listing 33 computes the value of samplesPerPage taking into account that only half as many samples from each data set can beplotted on a page as is the case when the plots of the two data sets are superimposed on the same axes in the class named PlotALot02 .

The overridden paint method

Additional code that I will highlight as being different is in the overridden paint method of the MyCanvas class. This code is shown in Listing 34 .

Listing 34. The overridden paint method.
public void paint(Graphics g){ //Draw horizontal axes//...code deleted for brevity//Plot the points if(sampleCounter>0){ for(int cnt = 0;cnt<= sampleCounter; cnt++){//Plot values from the blackData// array object. g.setColor(Color.BLACK);//Compute a vertical offset to locate// the black data on the odd numbered // axes on the page.int yOffset = ((1 + cnt*(sampSpacing + 1)/this.getWidth())*2*traceSpacing) - traceSpacing;//Draw an oval //...code deleted for brevity//Connect the sample values with // straight lines.//...code deleted for brevity//Plot the data stored in the // redData array object.g.setColor(Color.RED); //Compute a vertical offset to locate// the red data on the even numbered // axes on the page.yOffset = (1 + cnt*(sampSpacing + 1)/ this.getWidth())*2*traceSpacing;//Draw the ovals//...code deleted for brevity //Connect the sample values with// straight lines //...code deleted for brevity}//end for loop }//end if for sampleCounter>0 }//end overridden paint method}//end inner class MyCanvas }//end inner class Page}//end class PlotALot02

Some code was deleted for brevity

Most of the code in the overridden paint method is the same as the code that I discussed earlier and was deleted from Listing 34 for brevity.

The code that is different is the code that computes the vertical offset values to locate the black data on the odd numbered axes and to locate the reddata on the even numbered axes as shown in Figure 3 . I will let you work through the expressions in Listing 34 on your own and convince yourself that the code is correct.

Questions & Answers

if three forces F1.f2 .f3 act at a point on a Cartesian plane in the daigram .....so if the question says write down the x and y components ..... I really don't understand
Syamthanda Reply
hey , can you please explain oxidation reaction & redox ?
Boitumelo Reply
hey , can you please explain oxidation reaction and redox ?
Boitumelo
for grade 12 or grade 11?
Sibulele
the value of V1 and V2
Tumelo Reply
advantages of electrons in a circuit
Rethabile Reply
we're do you find electromagnetism past papers
Ntombifuthi
what a normal force
Tholulwazi Reply
it is the force or component of the force that the surface exert on an object incontact with it and which acts perpendicular to the surface
Sihle
what is physics?
Petrus Reply
what is the half reaction of Potassium and chlorine
Anna Reply
how to calculate coefficient of static friction
Lisa Reply
how to calculate static friction
Lisa
How to calculate a current
Tumelo
how to calculate the magnitude of horizontal component of the applied force
Mogano
How to calculate force
Monambi
a structure of a thermocouple used to measure inner temperature
Anna Reply
a fixed gas of a mass is held at standard pressure temperature of 15 degrees Celsius .Calculate the temperature of the gas in Celsius if the pressure is changed to 2×10 to the power 4
Amahle Reply
How is energy being used in bonding?
Raymond Reply
what is acceleration
Syamthanda Reply
a rate of change in velocity of an object whith respect to time
Khuthadzo
how can we find the moment of torque of a circular object
Kidist
Acceleration is a rate of change in velocity.
Justice
t =r×f
Khuthadzo
how to calculate tension by substitution
Precious Reply
hi
Shongi
hi
Leago
use fnet method. how many obects are being calculated ?
Khuthadzo
khuthadzo hii
Hulisani
how to calculate acceleration and tension force
Lungile Reply
you use Fnet equals ma , newtoms second law formula
Masego
please help me with vectors in two dimensions
Mulaudzi Reply
how to calculate normal force
Mulaudzi
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