Skip to content

Generate

Sambit Paul edited this page Dec 2, 2023 · 10 revisions

The Generate class helps to generate waveforms for certain periodic functions. As of now, the class supports generating the following functions:

  1. Sine Signal
  2. Cosine Signal
  3. Square Signal
  4. Sawtooth Signal
  5. Gaussian Pulse
  6. Unit Impulse
  7. Morlet Wavelet
  8. Ricker Wavelet
  9. Paul Wavelet
  10. Chirp Signal

All the signals generated here have a sampling frequency of 100Hz and signal frequency of 10Hz.

Sine Wave

sine

Code
int Fs = 100;
Generate gp = new Generate(Fs);
int f1 = 10;
double[] out = gp.generateSineWave(f1);

Cosine Wave

cosine

Code
int Fs = 100;
Generate gp = new Generate(Fs);
int f1 = 10;
double[] out = gp.generateCosineWave(f1);

Square Wave

square

Code
int Fs = 100;
Generate gp = new Generate(Fs);
int f1 = 10;
double[] out = gp.generateSquareWave(f1);

Sawtooth Signal

sawtooth

Code
int Fs = 100;
Generate gp = new Generate(0, 1, Fs);
int f1 = 5;
double[] out_reg_sawtooth = gp.generateSawtooth(f1, 1); //Regular Sawtooth
double[] out_tri_sawtooth = gp.generateSawtooth(f1, 0.5); //Triangular Sawtooth
double[] out_inv_sawtooth = gp.generateSawtooth(f1, 0); //Inverse Sawtooth

Gaussian Pulse

gaussianpulse

Code
int Fs = 100;
Generate gp = new Generate(-1, 1, 2*Fs);
int f1 = 10;
double[] out = gp.generateGaussianPulse(f1);

Unit Impulse

unitimpulse

Code
int Fs = 100;
Generate gp = new Generate(0, 1, Fs);
double position = 0.5; //middle of the signal
double[] out = gp.generateUnitImpulse(position);

Morlet Wavelet

morlet

Code
int Fs = 100;
Generate gp = new Generate(0, 1, Fs);
int points = 100;
double omega0 = 5; //central frequency
double scaling = 1;
double[] out = gp.generateMorlet(points, omega0, scaling);

Ricker Wavelet

ricker

Code
int Fs = 100;
Generate gp = new Generate(0, 1, Fs);
int points = 100;
double width = 4; 
double[] out = gp.generateRicker(points, width);

Paul Wavelet

paul

Code
int Fs = 100;
Generate gp = new Generate(0, 1, Fs);
int order = 4;
int width = 11; 
double[] out = gp.generatePaul(order, width);

Chirp Signal

chirp

Code
int Fs = 100;
Generate gp = new Generate(0, 1, Fs);
double f0 = 0;
double f1 = 10;
double[] out = gp.generateChirp(f0, f1);
Clone this wiki locally