How can i repeatedly store a smaller matrices after manipulations in a specific place of a larger matrix.

1 次查看(过去 30 天)
i am trying to store smaller matrices in a larger matrix. e.g i have an empty large matrix(720 x 720),in it i'd like to store a (720 x 360) and (360 x 360) matrix. i want them to occupy positions starting from 0,0 to X=360,Y=720 and from (361,0) to X=720,Y=360 respectively.

回答(2 个)

Fabio Freschi
Fabio Freschi 2016-10-3
I think your first matrix should be 360x720 (and indexing starts with 1). Try this
% create the matrices
A = rand(360,720);
B = rand(360);
% fill the original matrix
M = [A; B zeros(360)];
  1 个评论
sibusiso Motsa
sibusiso Motsa 2016-10-3
Maybe my example was wrong. i have an image say(720x720) and i created a matrix A which is the same size to that of the image, what i am doing is B= subtract even columns from odd column and also C= subtract even rows from odd rows from the resultant matrix of the first operation(matrix B) and store these results at specific locations of the matrix A.

请先登录,再进行评论。


Joe Yeh
Joe Yeh 2016-10-3
编辑:Joe Yeh 2016-10-3
Here's a solution (apparently this will only work with a square matrix) :
im_result = zeros(size(im_original));
% Subtract even columns from odd columns and store in the first half of the result matrix
im_result(:, 1 : end/2) = im_original(:, 1:2:end) - im_original(:, 2:2:end);
% Subtract even rows from odd rows and store in the second half of the result matrix
im_result(:, end/2+1 : end) = (im_original(1:2:end, :) - im_original(2:2:end, :)).';
  3 个评论
sibusiso Motsa
sibusiso Motsa 2016-10-4
The picture depicts what i want to achieve, having a 720x720 image for example and obtain matrix A through column subtraction(odd-even) of the original image, matrix A1 obtained from row subtraction(odd-even) of mtrix A. matrix B obtained from column sub of A1, matrix B1 from row sub of B.repeating this process for a number of iteration.but my problem is storing these manipulations in one matrix which is the size of the original image/matrix

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by