Binning data across multiple vectors

조회 수: 2 (최근 30일)
Vivek Gupta
Vivek Gupta 2018년 5월 30일
답변: KSSV 2018년 5월 31일
Hello,
I have 3 cell arrays (x, y, z) with 10 vectors in each array. So that x array is made of vectors x1,x2...x10 and y and z arrays are similar. Components of the vectors in x and y arrays represent spatial coordinates and components of the vectors in z array represents a measurement at the corresponding spatial coordinates. Each vectors has ~10 components.
My goal is to bin the data spatially so that z values that are close to each other spatially (determined by x and y coordinate) will be grouped together. And then I will average those z values to produce a single averaged z value for each spatial bin.
Is there a function that could help do this? I want to avoid having many switch case statements within for loops.
Edit: something like Histcounts would work great but I believe that function only works for binning data in 1 vector rather than across 2 vectors.

답변 (1개)

KSSV
KSSV 2018년 5월 31일
You need to bin z into specified number of bins using histcounts. This histcounts also gives you indices of z which falls in a specific bin. Using those indices, you can pick respective (x,y) of z.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by