Physics and Engineering of Radiation Detection

(Martin Jones) #1

10.1. Standard Analysis Packages 595


Scatter, line, bar, and pie charts
Histograms

Animations
Polygons and surfaces

MATLAB also has three dimensional plotting capabilities. For example, one
can create surface, contour, or mesh plots from data and also create 3-D surfaces
interactively.


C.5 ProgrammingEnvironment

As stated earlier, MATLAB is a high level programming language with very strong
library support. There are very large number of mathematical and statistical func-
tions available in MATLAB that can be accessed through high level commands of
its language. MATLAB language is different from traditional programming lan-
guages in that it has a high level and very easy-to-use syntax. For example, the user
does not have to worry about declaring variables or initializing them before use. A
new user can learn the basic syntax very quickly and can even start writing the code
in the first learning session.


C.6 Examples

Let us now have a look at a few examples of MATLAB usage. What we want is
to first generate a time series consisting of three sinusoidal frequencies and white
noise. We then want to plot the series. After that we want to perform its Fourier
transform and plot the power spectral density. Although we can perform these tasks
on the command line interface of MATLAB but it is always better to write all
the commands in a macro and run it. The program written in the code editor of
MATLAB is shown in Fig.10.1.20. The different lines in the code are explained
below.


Line 1-3:Comments that are ignored by the compiler.

Line 5:Generates the time axis from 0 to 5 seconds at steps of 0.001 second.
This is equivalent to sampling the data at 1/ 0 .001 = 1kHz. Hence, according
to the Nyquist theorem, we should be able to identify frequencies of up to 500
Hzin the dataset.

Line 6: Generates the data (which could be ADC counts) consisting of four
sinusoids with frequencies of 50Hz, 100Hz, 150Hz, and 100Hz.Wehave
arbitrarily assigned weights to these sinusoids as well. The factor 300 is also
arbitrary and is meant to keep the data values positive at all times.

Line 7: Adds white (random) noise to the values generated in the previous
step.

Line 8: Creates first canvas for the figure. This is not needed if one intends
to generate only one figure.
Line 9:Plots the time series (see Fig.10.1.21).
Free download pdf