# How can I split a matrix into N different parts?

13 views (last 30 days)
Mete Naz on 12 Sep 2018
Commented: ANKUR KUMAR on 13 Sep 2018
Hey Guys, I have a matrix X (80,160), and I want to divide it in to 18 regions. You can find the regions specifications in the picture. I could divide them into 18 almost equal parts but that is not what I need.I actually could not figure out how to divide it into those kind of regions. I would appreciate if anybody can help. Thanks

jonas on 12 Sep 2018
What do you mean divide them? How do you want to store each part? Hint: an array must be rectangular.
Mete Naz on 12 Sep 2018
I want to store them as sub matrices basically. If you look at the picture you will see how I want to divide them into 18 parts

ANKUR KUMAR on 12 Sep 2018
Edited: ANKUR KUMAR on 12 Sep 2018
Firstly change data into polar coordinates, so that your complete data will change into angles and radius. After conversion, your data will be of dimension (360 [angles]* 100 [assumed as radius]) After this, you can easily crop data as your wish (as mentioned in your image).
You conversion will somewhat looks like
z=interp2(lon,lat,data,xx,yy);
where 'lon', 'lat' is the x and y coordinates of your rectangular dataset ('data')

Mete Naz on 12 Sep 2018
I have converted the data into polar coordinates. I am kind of new on matlab so I do not know How I am supposed to easily crop my data as shown in the picture? I would appreciate your help!
ANKUR KUMAR on 13 Sep 2018
After conversion into polar, your data will be in dimension of 360 * 100 (assuming angular resolution is 1 degree and radius has 100 units). As per your figure, suppose 1st part is around 60 to 120 degree and radius may be 66 to 100 units. Then simply do
A_cropped=A(60:120,66:100);
where A is the polar converted matrix.
The only hurdle in your problem is conversion. Once you are done with the conversion, it's very easy to crop the data as per your figure.