# 4.1 Java1482-spectrum analysis using java, sampling frequency,  (Page 17/24)

 Page 17 / 24

## The remainder of the method and the class

The nested for loops discussed above are included in the code shown in Listing 15 . As suggested above, the outer loop iterates on frequency while the inner loop iterates on the values that make up the incoming samples. The code inthe inner loop computes the sum of the product of the time series and the reference cosine and sine functions.

Listing 15. The remainder of the method and the class.
```//Outer loop iterates on frequency // values.for(int i=0; i<dataLen;i++){ double freq = lowF + i*delF;double real = 0.0; double imag = 0.0;double ang = 0.0; //Inner loop iterates on time-// series points. for(int j=0; j<dataLen; j++){ real += data[j]*Math.cos( 2*pi*freq*(j-zero));imag += data[j]*Math.sin(2*pi*freq*(j-zero)); }//end inner looprealOut[i]= real/dataLen; imagOut[i]= imag/dataLen; magnitude[i]= (Math.sqrt( real*real + imag*imag))/dataLen;//Calculate and return the phase // angle in degrees.if(imag == 0.0&&real == 0.0){ang = 0.0;} else{ang = Math.atan(imag/real)*180.0/pi;}if(real<0.0&&imag == 0.0){ang = 180.0;} else if(real<0.0&&imag == -0.0){ ang = -180.0;}else if(real<0.0&&imag>0.0){ ang += 180.0;}else if(real<0.0&&imag<0.0){ ang += -180.0;}angleOut[i] = ang;}//end outer loop }//end transform method}//end class ForwardRealToComplex01```

## Store results in output array objects

At the end of each iteration of the inner loop, code in the outer loop deposits the real, imaginary, magnitude, and phase angle results in the outputarray objects. To accomplish this, the code:

• Computes the magnitude or amplitude as the square root of the sum of the squares of the real and imaginary parts.
• Performs some trigonometry operations to determine the phase angle in degrees based on the values of the real and imaginary parts.

## Now you know about the dft algorithm

Now you know about the DFT algorithm. You also know about some of the fundamental aspects of spectral analysis involving the sampling frequency andthe folding frequency.

Future modules will discuss other aspects of spectral analysis including:

• Frequency resolution versus data length.
• The relationship between the phase angle and delays in the time domain.
• The reversible nature of the Fourier transform involving both forward and inverse Fourier transforms.

## Spectral analysis using an FFT algorithm

At this point, I will present a similar spectral analysis program that uses an FFT algorithm. I will present this program with very little discussion. I amproviding it in this module for two primary purposes:

• To allow you to experiment and appreciate the flexibility of the DFT as compared to the FFT.
• To allow you to experiment and appreciate the speed of the FFT as compared to the DFT.

## The program named Dsp030

The program named Dsp030 is very similar to Dsp028 . The major differences are:

anyone know any internet site where one can find nanotechnology papers?
research.net
kanaga
Introduction about quantum dots in nanotechnology
what does nano mean?
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
it is a goid question and i want to know the answer as well
Maciej
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
are you nano engineer ?
s.
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.
Tarell
what is the actual application of fullerenes nowadays?
Damian
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.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
for screen printed electrodes ?
SUYASH
What is lattice structure?
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
what's the easiest and fastest way to the synthesize AgNP?
China
Cied
types of nano material
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
Got questions? Join the online conversation and get instant answers!