Use of accumarray function

Hi everybody;
Please find here below my question :
I have 3D available data : Xaxis : AZ, Yaxis : EL, Zaxis : Gain, whose Xaxis & Yaxis data are non regular
1. I need to define some 2D cells in order to slice all the AZ,EL data into regular cells (For instance, size of a cell is +/-0.1° in AZ & EL)
There are a lot of the cell that will be empty as only few cuts measurement are available.
2. As several acquisitions are made, we can get different value of Gain within a same cell region.
I need to average the Gain within each cell when there are different value.
But, I would like to avoid to read all the data one by one, and to fill the cell one by one to average them
I’ve seen the function "accumarray" that seems to solve this kind of question, but i can not really figure out how to use it ...
Could a good soul help me ?. Thanks a lot for your advise

2 件のコメント

Guillaume
Guillaume 2019 年 9 月 24 日
An example of the input data would really be useful.
Matt J
Matt J 2019 年 9 月 24 日
Stephane's comment moved here:
yes, please find a simple exemple of the data (i join also the file exemple.csv), that provide about 100 points with just one cut along AZ and one cut in EL.
Hope this help.

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

回答 (1 件)

Matt J
Matt J 2019 年 9 月 24 日
編集済み: Matt J 2019 年 9 月 24 日

0 投票

For example,
AZ=AZ(:); EL=EL(:); Gain=Gain(:);
AZedges=min(AZ)-0.1:0.2:max(AZ)+0.1; ELedges=min(EL)-0.1:0.2:max(EL)+0.1;
subs=[discretize(AZ,AZedges), discretize(EL,ELedges)];
cellMeans=accumarray(subs,Gain,[],@mean);

4 件のコメント

Matt J
Matt J 2019 年 9 月 26 日
Stephane's comment moved here:
Thanks a lot Matt, i've increased the AZedges & ELedges maximum by one step to get discretized the max data and it works very well.
So now i've a 2D array with the Gain means value.
Is there an easy way to come back to initial format (3 columns) by removing all rows that get a "0" in the table, I mean datas with a column AZedges, a column with ELedges and the Mean gain data, but only with the relevant one.
Again i would like to avoid to do it by "crossing" the cell one by one.
Thansk a lot
Matt J
Matt J 2019 年 9 月 26 日
You can use find(),
[AZbin,ELbin,Gain]=find(cellMeans);
threeColumns=[AZbin,ELbin,Gain];
Matt J
Matt J 2019 年 9 月 30 日
Stephane Tess' comment move here:
Thanks you very much Matt !
Matt J
Matt J 2019 年 9 月 30 日
You're welcome, but please Accept-click the answer if it lead to a solutionfor you.

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

カテゴリ

タグ

質問済み:

2019 年 9 月 24 日

コメント済み:

2019 年 9 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by