Operations on sequences of numbers
In the last session we generated a sequence of numbers using the program coswave.c. Let's call the sample number i and the i'th sample x[i]:
0
|
32000
|
1
|
30601
|
2
|
26529
|
3
|
20138
|
4
|
11987
|
5
|
2788
|
6
|
-6654
|
7
|
-15514
|
8
|
-23019
|
9
|
-28513
|
10
|
-31514
|
11
|
-31762
|
12
|
-29234
|
13
|
-24151
|
14
|
-16958
|
15
|
-8283
|
16
|
1116
|
17
|
10418
|
18
|
18809
|
19
|
25556
|
20
|
30070
|
Some simple operations on lists of numbers:
1) Sum or integral, x[i]. If x[i] has positive and negative values, it is better to take the absolute (i.e. unsigned) value of x[i], written |x[i]|. The most common way of calculating this is to first calculate the square of x[i], x[i]2, and then take the square root,
x[i]2. This is a measure of the overall energy of a signal.
2) Obviously, x[i]2 gets bigger and bigger as x[i] gets longer. More usually, we are interested in the average amplitude of a signal, as calculated over n samples: (
x[i]2/n). This is called the root mean square or RMS amplitude, since it is the square root of the mean of the square of n samples.
A C program for calculating RMS amplitude is given here.
3) Local averaging ... (follow the link).