Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

matlab - 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?

question from:https://stackoverflow.com/questions/65651997/calculate-mean-of-a-timed-signal

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...