Alucard8
Alucard8

Reputation: 3

Calculate mean of a timed signal

I have a function rapresenting a signal, where x-axis are times and y-axis are signal volts. Signal seems to be sampled at 200Hz, even if for some "times" it have 199 samples and not 200 as expected.

Following is an example of my signal data (TIME - SIGNAL):

0 - 2.56
0.12325 - 2.58
0.134564 - 2.6233
...
1.2133 - 2.45
1.3425 - 2.56
...

For the second 0 I have 200 samples, and for second 1 I have 199 samples (and not 200 as expected).

My asks is: how to calculate mean and variance of the entire signal? My ask is due to the fact that normally I calculate the mean and variance without the "TIME" information, I need to take care also about "time information" in my case, or not?

Upvotes: 0

Views: 77

Answers (1)

Kenneth Boyd
Kenneth Boyd

Reputation: 667

Here is the code that creates some sample data, there are 2 columns, the first is time and the second is volts:

data = [0, 2.56; ...
        0.12325, 2.58; ...
        0.134564, 2.6233; ...
        1.2133, 2.45; ...
        1.3425, 2.56];

Here is the code that calculates the mean and variance. The : in the first location means to use all rows, the 2 means to use the second column. This will work with any number of rows.

mean_data = mean(data(:, 2))
variance_data = var(data(:, 2))

Upvotes: 1

Related Questions