# Discretizing a column array, and performing operations on elements of another column array of the same length that lie in the same bins as the original one

6 Ansichten (letzte 30 Tage)
Saeid am 26 Feb. 2024
Bearbeitet: Catalytic am 26 Feb. 2024
I have a data array that is composed of column vectors X, Y, & Z (coordinates) and an array F that has one or multiple columns of the same length. The number of rows of A is usually in the order of 100k to even a couple of million, so that I need to reduce this number to a fraction of that. Let's assume:
A=[X Y Z F]
X, Y & Z are column vectors of length i, and F is an array with i rows and j columns.
Using the discretize command,I would like to discretize column Z into a column with a lower number of rows (let's say going from i rows to only i/1000 rows), and I would like to calculate the average value of every individual coumn of F that lies in the same bin as the discretized Z.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Matt J am 26 Feb. 2024
G=findgroups( discretize(Z,edges) );
Fbinned = splitapply(@(z) mean(z,1) , F, G);
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Catalytic am 26 Feb. 2024
Bearbeitet: Catalytic am 26 Feb. 2024
I=findgroups(discretize(Z,edges)) ;
S=sparse(I,(1:numel(I))', 1);
S=S./sum(S,2);
Fbinned = S*F;
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Logical finden Sie in Help Center und File Exchange

R2023b

### Community Treasure Hunt

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

Start Hunting!

Translated by