How can i repeatedly store a smaller matrices after manipulations in a specific place of a larger matrix.
1 view (last 30 days)
Show older comments
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.
1 Comment
Pablo Rodriguez
on 3 Oct 2016
You could use cell arrays:
A = zeros(720,360);
B = zeros(360,360);
Matrix={A,B};
Let me know if it helps you :)
Answers (2)
Fabio Freschi
on 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)];
Joe Yeh
on 3 Oct 2016
Edited: Joe Yeh
on 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 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!