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

Using graph06 to plot the sinusoidal data

The plotting program named Graph06 can be used to plot the sinusoidal data as follows:

  • Define and compile the program named Dsp029 , implementing the interface named GraphIntfc01 . The definition of that interface is shown in Listing 5
  • Compile the program named Graph06 . Then start the plotting program named Graph06 running by entering the command shown below at the command line prompt.
java Graph06 Dsp029

The code for graphintfc01

Listing 5. The code for GraphIntfc01.
public interface GraphIntfc01{ public int getNmbr();public double f1(double x); public double f2(double x);public double f3(double x); public double f4(double x);public double f5(double x); }//end GraphIntfc01

What does this do?

When executed in this manner, the program named Graph06 instantiates an object of the class named Dsp029 and then calls the interface methods on that object to obtain the data to be plotted.

In this case, the constructor for the Dsp029 class populates the five array objects with sinusoidal data. The subsequent call to theinterface methods by the program named Graph06 causes that sinusoidal data to be retrieved and plotted by Graph06.

The graphintfc01 interface methods

A brief description of each of the interface methods is provided in the following sections.

The getnmbr method

Plotting programs based on GraphIntfc01 can be used to plot any number of functions from one to five.

The method named getNmbr must return an integer value between 1 and 5 that specifies the number of functions to be plotted. Theplotting program uses that value to divide the total plotting surface into the specified number of plotting areas, and plots each of the functions named f1 through fn in one of those plotting areas.

The methods named f1, f2, f3, f4, and f5

As you can see in Listing 5 , each of these methods receives a double value as an incoming parameter and returns a double value. In essence, each of thesemethods receives a value for the horizontal coordinate x and returns the corresponding value for the vertical coordinate y.

One plotting area per method

Each of these methods provides the data to be plotted in one plotting area. The method named f1 provides the data for the top plotting area; the method named f2 provides the data for the first plotting area down from the top, and so forth.

(For example, if the getNmbr method returns a value of 4, the method named f5 will never be called. If getNmbr returns 5, the method named f5will be called to provide the data for the bottom plotting area.)

How does it work?

Each plotting area contains a horizontal axis. The plotting program moves across the horizontal axis in each plotting area one step at a time (moving in incremental steps equal to the plotting parameter named xCalcInc , which you will find if you examine the code for Graph06 ) .

At each step along the way, the plotting program calls the method associated with that plotting area, ( f1 , f2 , etc.) , passing the horizontal position as a parameter to the method.

The value returned by the method is assumed to be the vertical value associated with that horizontal position, and that is the vertical value that isplotted for that horizontal position.

Questions & Answers

what is mutation
Janga Reply
what is a cell
Sifune Reply
how is urine form
Sifune
what is antagonism?
mahase Reply
classification of plants, gymnosperm features.
Linsy Reply
what is the features of gymnosperm
Linsy
how many types of solid did we have
Samuel Reply
what is an ionic bond
Samuel
What is Atoms
Daprince Reply
what is fallopian tube
Merolyn
what is bladder
Merolyn
what's bulbourethral gland
Eduek Reply
urine is formed in the nephron of the renal medulla in the kidney. It starts from filtration, then selective reabsorption and finally secretion
onuoha Reply
State the evolution relation and relevance between endoplasmic reticulum and cytoskeleton as it relates to cell.
Jeremiah
what is heart
Konadu Reply
how is urine formed in human
Konadu
how is urine formed in human
Rahma
what is the diference between a cavity and a canal
Pelagie Reply
what is the causative agent of malaria
Diamond
malaria is caused by an insect called mosquito.
Naomi
Malaria is cause by female anopheles mosquito
Isaac
Malaria is caused by plasmodium Female anopheles mosquitoe is d carrier
Olalekan
a canal is more needed in a root but a cavity is a bad effect
Commander
what are pathogens
Don Reply
In biology, a pathogen (Greek: πάθος pathos "suffering", "passion" and -γενής -genēs "producer of") in the oldest and broadest sense, is anything that can produce disease. A pathogen may also be referred to as an infectious agent, or simply a germ. The term pathogen came into use in the 1880s.[1][2
Zainab
A virus
Commander
Definition of respiration
Muhsin Reply
respiration is the process in which we breath in oxygen and breath out carbon dioxide
Achor
how are lungs work
Commander
where does digestion begins
Achiri Reply
in the mouth
EZEKIEL
what are the functions of follicle stimulating harmones?
Rashima Reply
stimulates the follicle to release the mature ovum into the oviduct
Davonte
what are the functions of Endocrine and pituitary gland
Chinaza
endocrine secrete hormone and regulate body process
Achor
while pituitary gland is an example of endocrine system and it's found in the Brain
Achor
what's biology?
Egbodo Reply
Biology is the study of living organisms, divided into many specialized field that cover their morphology, physiology,anatomy, behaviour,origin and distribution.
Lisah
biology is the study of life.
Alfreda
Biology is the study of how living organisms live and survive in a specific environment
Sifune
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