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.
댓글 수: 1
Pablo Rodriguez
2016년 10월 3일
You could use cell arrays:
A = zeros(720,360);
B = zeros(360,360);
Matrix={A,B};
Let me know if it helps you :)
답변 (2개)
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)];
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!