doulbe the size of all elements in a matrix

Hi, I make 320 by 240 pixel matrices that I need to convert to 640 x 480. But, i want A(1,1) to go into B(1,1), B(1,2), B(2,1) and B(2,2) so that I am in effect doubling the size of the whole thing. is there a function that can do that?

More Answers (1)

There is no specific function that does this, but you can use 'repmat' to accomplish that:
B = A(repmat(1:size(A,1),2,1),repmat(1:size(A,2),2,1));
or else you can use 'ceil' as follows:
B = A(ceil((1:2*size(A,1))/2),ceil((1:2*size(A,2))/2));
(Actually you are quadrupling the size of A.)

Categories

Products

Community Treasure Hunt

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

Start Hunting!