How to use splitapply function to find a mean value for part of plot ?

4 ビュー (過去 30 日間)
Ilkin Abdullayev
Ilkin Abdullayev 2020 年 5 月 15 日
コメント済み: Ilkin Abdullayev 2020 年 5 月 19 日
Hello Everyone,
I am in trouble with splitapply function. It is a bit difficult to describe here but I will try.
I have upload picture and as it is specified in the picture with the horizontal red lines, i have separated my whole circle into the section with 4 cm distance.
Now, what I want to do, in each section I have load value and I need a mean value for each section.
I think by using the splitapply we can split the whole data into the section with 4 cm each but do not how to do.
If you have any suggestion to do this beside splitapply please let me know.
I have a different colours for load and after finding the mean load value for each section based on my color scale, I will have a kind of bar graph with different colors in each section - This parts is just to explain that what is my main target.
If someone can help I really appreciate. I hope my question is clear.
Thanks
  2 件のコメント
dpb
dpb 2020 年 5 月 15 日
Use histcounts w/ optional third output bin as the grouping variable.
Ilkin Abdullayev
Ilkin Abdullayev 2020 年 5 月 15 日
Could you please specify, how can I apply this function. I am not very close with this code.

サインインしてコメントする。

回答 (1 件)

darova
darova 2020 年 5 月 15 日
try round
y1 = round(y-min(y))+1; % make all yy values 1 2 3 4 ...
n = max(y1); % highest number
a = zeros(n,1); % preallocate mean value
m = zeros(n,1); % preallocate number of values in section
for i = 1:numel(y1)
i1 = y1(i);
m(i1) = m(i1) + 1; % increase number of values
a(i1) = a(i1) + val(i1); % sum values
end
a = a./m;
  3 件のコメント
darova
darova 2020 年 5 月 18 日
I see that your data is splitted in [-4 -3 ... 3 4] sections. So i just rounded all your data such that all values of green points [1 2 ... 7 8]
Example. I want to split data (circle radius 3) in section of 0.5 size. So i replaced data to 'zero' point and multiplied by 2 , rounded and divided by 2. Finally moved to origin
[x,y] = pol2cart(0:.1:2*pi,3);
y1 = round( (y-min(y))*2 )/2 + min(y);
plot(x,y,'.-r')
hold on
plot(x,y1,'ob')
hold off
axis equal
Ilkin Abdullayev
Ilkin Abdullayev 2020 年 5 月 19 日
Thanks a lot, I will try your way.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by