Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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.

Réponses (2)

Fabio Freschi
Fabio Freschi le 3 Oct 2016
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 commentaire
sibusiso Motsa
sibusiso Motsa le 3 Oct 2016
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.

Connectez-vous pour commenter.


Joe Yeh
Joe Yeh le 3 Oct 2016
Modifié(e) : Joe Yeh le 3 Oct 2016
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 commentaires
sibusiso Motsa
sibusiso Motsa le 4 Oct 2016
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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by