Split 7000x4000 matrix in 10x10 matrices?
이전 댓글 표시
Hi,
I have a 7000x4000 Matrix of topographic data that I need to split into 10x10 matrices (Split by going every 10 rows and 10 columns). Any recommendations on how to go about it? Also once the matrix is split into the 10x10 matrices, I need it to randomly select 1 number out of the 100 in each matrices?
Regards, Akshay
채택된 답변
추가 답변 (1개)
Image Analyst
2016년 8월 7일
편집: Image Analyst
2016년 8월 7일
One way:
rows = 7000;
columns = 4000;
% Get starting points in upper left.
[R, C] = meshgrid(1:10:rows, 1:10:columns);
% Get coordinates of random point in each 10x10 tile
R = round(R + 10 * rand(size(R)));
C = round(C + 10 * rand(size(C)));
Now R and C have all of your coordinates - one from each 10 by 10 tile over the whole image. You can get a value from, say, the tile in the second row and the 5th column of tiles like this
value = yourMatrix(R(2), C(5));
Where yourMatrix is your full sized 7000x4000 matrix.
댓글 수: 1
Image Analyst
2016년 8월 10일
Solution to your request for points to be normally distributed from the center of each 10-by-10 tile.
rows = 7000;
columns = 4000;
% Get starting points in upper left.
[R, C] = meshgrid(1:10:rows, 1:10:columns);
% Get coordinates of random point in each 10x10 tile
mu = 5;
sigma = 2.5;
rRand = mu + sigma * randn(size(R));
cRand = mu + sigma * randn(size(C));
% Don't let go less than 0
rRand(rRand<0) = 0;
cRand(cRand<0) = 0;
% Don't let go more than 10
rRand(rRand>10) = 10;
cRand(cRand>10) = 10;
% Get the random coordinates - one from each 10-by-10 tile.
randomRows = round(R + rRand);
randomCols = round(C + cRand);
scatter(randomRows(:), randomCols(:), 1);
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!