Previous Getting Started with IDL: Signal Processing with IDL Next

Creating a Data Set

First, we need to create a dataset to display.

  1. Enter the following command to create a sinewave function with a frequency that increases over time and store it in a variable called ORIGINAL:
  2. ORIGINAL=SIN((FINDGEN(200)/35)^2.5)  
    

     

    The FINDGEN function returns a floating-point array in which each element holds the value of its subscript, giving us the increasing "time" values upon which the sinewave is based. The sine function of each "time" value divided by 35 and raised to the 2.5 power is stored in an element of the variable ORIGINAL.

     

  3. To view a quick plot of this dataset, shown in the following, enter:
  4. PLOT, ORIGINAL  
    

     

    Figure 5-1: Plot of Increasing Frequency

    Figure 5-1: Plot of Increasing Frequency

     

  5. Now add some uniformly-distributed random noise to this dataset and store it in a new variable:
  6. NOISY=ORIGINAL+((RANDOMU(SEED,200)-.5)/ 2)  
    

     

  7. Now plot the array:
  8. PLOT, NOISY  
    

     

    Figure 5-2: Plot of Random Noise

    Figure 5-2: Plot of Random Noise

     

    The RANDOMU function creates an array of uniformly distributed random values. The original dataset plus the noise is stored in a new variable called NOISY. This dataset looks more like real-world test data.

     

  9. Display the original dataset and the noisy version simultaneously by entering the following commands:
  10. PLOT, ORIGINAL, XTITLE="Time",YTITLE="Amplitude",THICK=3  
    

     

  11. Then overplot the previous data:
  12. PLOT, NOISY, /OVERPLOT  
    

     

    The XTITLE and YTITLE keywords are used to create the X and Y axis titles. The OPLOT command plots the NOISY dataset over the existing plot of ORIGINAL without erasing. Setting the THICK keyword causes the default line thickness to be multiplied by the value assigned to THICK, so you can differentiate between the data. This result can be seen in the following figure.

     

    Figure 5-3: Combined Plotting of Datasets

    Figure 5-3: Combined Plotting of Datasets

  IDL Online Help (March 06, 2007)