Averaging points within data set

7 次查看(过去 30 天)
Hi,
I have some data that I have got from an engine. This data is pressure from a certain point with the engine. To acquire this data I had the engine complete 200 revolutions of the full 720 degree cycle.
My issue now is that i have 200 sets of 720 data points.
The output data goes;
data set 1 - degree 1
data set 1 - degree 2
data set 1 - degree 3
...all the way to degree 720.
data set 2 - degree 1
data set 2 - degree 2
data set 2 - degree 3
...all the way to degree 720.
data set 3 - degree 1
data set 3 - degree 2
data set 3 - degree 3
...all the way to degree 720.
All the way to data set 200
Is there a way that I can set the average value of degree 1 from data set 1, data set 2, data set 3...all the way to data set 200 and be able to do this for all of 720 degrees?
  2 个评论
dpb
dpb 2017-8-13
Well, are the data all in one file, 200 files or in memory as a very long vector or what, precisely? It'll be simple enough to do once we have a more precise definition of just what a "data set" really is...
Lewis Parry
Lewis Parry 2017-8-15
编辑:Lewis Parry 2017-8-15
The 200 sets of data are within a single txt file. I have put an image of the data I get in the post below

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2017-8-15
编辑:Andrei Bobrov 2017-8-15
x=importdata('yourfile.txt');
xavg=accumarray(rem((0:numel(x)-1).',720)+1,x(:),[],@mean);

更多回答(2 个)

Mike Caldwell
Mike Caldwell 2017-8-14
Do you mean you want to GET the average across all of your data sets? If performance isn't an issue, you could use for loops. Assuming your dataset is in matrix form (if not you could arrange it like this):
Arrangement:
row 1: 1 ... 720
row 2: 1 ... 720
. . . . . . . .
row 200: 1 ... 720
Code:
average = zeros(1, 720);
sum = 0;
for i = 1:720
for j = 1:200
sum = sum + dataset(j, i); //add all the values in ith column
end
average(i) = sum/200; //then take the average
sum = 0;
end
Hope that answers it. -Mike
  1 个评论
Lewis Parry
Lewis Parry 2017-8-15
编辑:Lewis Parry 2017-8-15
Hi Mike thank you very much for your help. What you have said is helpful, but I don't think that I explained the way that the data was set out very well.
The data come in a single column text file with it giving the data for dataset1 - sample 1 sample2 sample3 ... sample 720 dataset2 sample 1 sample2 sample3 ... sample 720.
I have attached an image of the data that I get and an excel document of the data I want to get from the file.
Thanks for your help!

请先登录,再进行评论。


dpb
dpb 2017-8-15
编辑:dpb 2017-8-15
I can't read the image to tell what the data file name is, but given the data are just a linear sequence so don't have to do any file manipulations to get them in a useful sequence the solution is almost trivial--
x=importdata('yourfile.txt'); % read all the data in the column
xavg=mean(reshape(x,720,[]),2); % average the 200 columns of 720 rows by row
What this relies on is internal storage order and using the vector abilities in Matlab to arrange the data into an array by the sequential samples. You have 720 samples for each cycle so rearranging by that as the first dimension leaves the total number/720 columns, for each of the "tests". Then, use the optional second DIM argument to the mean function to average over those columns. (Of course, you could also transpose the result of the reshape operation and average columns and get the same result.)

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by