MATLAB Answers

# Breaking coordinate system into sections and finding the mean of each secction

17 views (last 30 days)
Luke Kuklenski on 19 Feb 2021
Answered: Shadaab Siddiqie on 22 Feb 2021
I have a matrix of (X,Y,Q) values. X is the x coordinate, Y is the y coordinate, and Q is the value at that point. There are thousands of data points for a given 100mm by 100mm area of X and Y. I need to write a code where I can break the coordinate system into a certain unknown number of equal size sections and take the mean of all Q values that fall in each section.
For example, take the mean of all Q values that fall within x = {0,5} and Y = {0,5}.
##### 1 CommentShowHide None
darova on 20 Feb 2021
Do you have any attempts?

Sign in to comment.

### Answers (1)

Shadaab Siddiqie on 22 Feb 2021
From my understanding you want to split the matrix into equal size sections (i am assuming they are continuous) and find the mean of each section. Here is an basic idea to do that :
To select random number of sections :
• Select random no of random rows.
• Select random no of random columns.
• Then split the matrix with these rows and column
To get the mean:
• Create cumulative matrix using
CM = cumsum(Matrix,2);
• Get sum of submatrix (section) from the cumulative sum to improve the performance
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!