开发者

Restoring an extracted sub-matrix after necessary modification into the original matrix from which it is extracted using Matlab

开发者 https://www.devze.com 2023-04-06 11:28 出处:网络
I have a huge 2D matrix. After extracting as many as possible sub-matrices of size 8*8开发者_开发技巧 from this 2D matrix, i made certain necessary modifications in the sub-matrices.

I have a huge 2D matrix. After extracting as many as possible sub-matrices of size 8*8开发者_开发技巧 from this 2D matrix, i made certain necessary modifications in the sub-matrices. Now i want to re-constitute the original 2D matrix by replacing the extracted sub-matrices with the corresponding new modified sub-matrices. The positions of each of the elements in both the extracted sub matrix as well as the corresponding new modified sub matrix should be the same in the original 2D matrix. How can i do this using Matlab? Thank you.


% let's generate a big 100x100 matrix
big_matrix = rand(100, 100);

% the indices of an exemplary small matrix
sm_x = 20:27;
sm_y = 20:27

% the small matrix
small_matrix = big_matrix(sm_x:sm_y);

% let's modify the small matrix - replace this line with your own code
small_matrix(small_matrix > 0.5) = 1;

% let's write the modified small matrix back to the original position
big_matrix(sm_x:sm_y) = small_matrix;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号