doulbe the size of all elements in a matrix

2 views (last 30 days)
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?

Accepted Answer

Sean de Wolski
Sean de Wolski on 20 Mar 2014
B = kron(A,ones(2));

More Answers (1)

Roger Stafford
Roger Stafford on 20 Mar 2014
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

Find more on Matrices and Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!