Averaging points within data set
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lewis Parry
am 13 Aug. 2017
Kommentiert: Andrei Bobrov
am 15 Aug. 2017
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 Kommentare
dpb
am 13 Aug. 2017
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...
Akzeptierte Antwort
Andrei Bobrov
am 15 Aug. 2017
Bearbeitet: Andrei Bobrov
am 15 Aug. 2017
x=importdata('yourfile.txt');
xavg=accumarray(rem((0:numel(x)-1).',720)+1,x(:),[],@mean);
1 Kommentar
Weitere Antworten (2)
Mike Caldwell
am 14 Aug. 2017
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 Kommentar
dpb
am 15 Aug. 2017
Bearbeitet: dpb
am 15 Aug. 2017
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.)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
