How to find a mean value after each 360 degree?

Hello everyone,
I urgently need your help. I have a data 50000x5 and my 1 column is degree such as 1.5,1.45,2,1.35 and so on.
I need to calculate a mean value after each 360 degree for whole data but do not know how to do.
If anyone can help I would be very glad.
Thanks in advance.

4 comentarios

darova
darova el 20 de Mayo de 2020
Do you have any attempts?
Ilkin Abdullayev
Ilkin Abdullayev el 20 de Mayo de 2020
I tried to filter data which range between 0-1.5.
Then find a mean value for filtered data.
% filtereddata=new3536((new3536.Angle)>0&(new3536.Angle)<1.5,:);
% meanvalue=mean(filtereddata);
Then by using the loop function to do it for the whole data. But I am not sure if it is the right way.
One another option which I think could work, is to use splitapply function to groupd the data based on the value of other column then find a mean. Actually I have 2 column that I can use to calculate mean for the rows which correspond 360 degree. But the best could the angle column because it gives the perfect results witouht any doupt.
darova
darova el 21 de Mayo de 2020
Here is how i understand oyour question: You want to divide each cycle as following
My question: where is the points of breakup? 180? 360?
Ilkin Abdullayev
Ilkin Abdullayev el 21 de Mayo de 2020
so, there is no known point for this purposes. Let me to explain.
In my data as you can see one column is the degree and for example if I do it in excel manualy, I sum up first 243 row (example) for angle and obtain 360 degree. Then next 360 degree is between 244 500 for example. The thing is the number of the rows that we need sum up for obtaining 360 degree is not the same always. So what I need, to find a mean value for each 360 degree. I hope now its clear.

Iniciar sesión para comentar.

 Respuesta aceptada

darova
darova el 21 de Mayo de 2020
Try this
A = importdata('meanvalue.csv',',');
%%
B = cumsum(diff(A,2,1));
B(end+1,:) = -inf;
k = 1;
s = 1;
for i = 1:size(B,1)
if B(i,1) < -pi % end of cycle
s = s + 1; % group counter
A(k:i,3) = mean(A(k:i,2)); % calculate mean
A(k:i,4) = s; % assign group number
k = i; % index of next group
end
end
t = A(:,1);
r = cumsum(A(:,2));
[x,y] = pol2cart(t,r);
plot(x,y)
hold on
scatter(x,y,5,A(:,4),'fill')
hold off

7 comentarios

Ilkin Abdullayev
Ilkin Abdullayev el 21 de Mayo de 2020
Thanks a lot I will try this code soon. But since your plot just confused me, let me to point out other detailes about the mean value which I am looking for. Then if there is any misunderstanding we can correct. Well this just example: I have 500000×3. My first column is degree for example-1.5,1,1.45,1.25...... My second column is pressure for example 100,200,300... My third column is temperature for example 10,45,35...
So based on my first column,I need to calculate mean value after each 360 degree. Lets suppose when I sum up my first 243 row I obtain 360 degree for 1st row. Then I need a mean value for 243 rows for 2nd and 3rd column. I will have a result for example.
(150(pressure),35(temperature). So I need to calculate the mean after each 360 degree.
Sorry for re-explanation I just wanted to be clear since the plot just confused me.
darova
darova el 21 de Mayo de 2020
I think everything is ok. Thanks for additional explanations
Don't be confused about th epicture i attached. It's your data (modificated). Just note that every 360 degree color of points is different
Ilkin Abdullayev
Ilkin Abdullayev el 22 de Mayo de 2020
I tried this code, it gave some result I mean there is no error but It does not give any mean value. I mean we need to have 1 value for second row based on 360 degree of the 1st but it does not. Just some changes happen in data. Another thing which I noticed in data that I have upload the wrong data I mean when we sum up the degrees manually it does not reach to 360 degree. Maybe this could be the reason. So I upload the new file with the same name. In the new data, the first 239 row is 360 degree and corresponding mean value for the second row is 99264.45 (from manual excel calculation).
Ilkin Abdullayev
Ilkin Abdullayev el 22 de Mayo de 2020
One more possibility I am not sure if it works or not. The data I upload last is the selected part of the very big data. But maybe by using very big data we can obtain something. I mean in the my big data lets call it "X" one of the column is ID number. We have 4 different ID number which is 35,28,22 and 15. I will a part of data and you will see how they placed in the column. What we might do, is to calculate mean value for the groups that contain 35 for example.
I mean, in data lets suppose the first 45 row's ID is 35, then we have some row of 28 then 22 then 15.
Then it starts againg with 35 and repeat the sequence. However the number of rows is not the same both between different IDs and the same. So instead of 360 degree concept, maybe we can calculate the mean for the first group of 35,the second 35 , third 35 and so on. So at the end we will have individual mean values for each 35 group.
darova
darova el 22 de Mayo de 2020
Please see this
Ilkin Abdullayev
Ilkin Abdullayev el 22 de Mayo de 2020
Yes, I agree with you. Just take a look picture that I have upload. You can notice from the size of data and also I will leave the result that you can see it does not give the mean just change the values. I mean normally we must have one number as a mean for whole rows but there is no this number.
I obtain the same graph that you obtain and do not change anything even use for the same data but no mean value which must be 1 number.
Ilkin Abdullayev
Ilkin Abdullayev el 22 de Mayo de 2020
Sorry, I just noticed one thing which is mean value. Thank a lot . I really appreaciate your support

Iniciar sesión para comentar.

Más respuestas (1)

Categorías

Preguntada:

el 20 de Mayo de 2020

Comentada:

el 22 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by