My array size is 32 x 240,now i want to pad zeros to make it as 192 x 240.How to do it using matlab code
1 view (last 30 days)
Show older comments
kaavya subramani
on 31 Jul 2015
Commented: kaavya subramani
on 1 Aug 2015
x = [zeros(floor(ls/2),n) x zeros(ceil(ls/2),n)];
i am getting error as
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
so i checked size of all 3.i.e size of zeros(floor(ls/2),n) is 32 x 240, whereas size of zeros(ceil(ls/2),n) is 32x240. size of x is 192:240.
Accepted Answer
Walter Roberson
on 31 Jul 2015
x = [zeros(floor(ls/2),n); x; zeros(ceil(ls/2),n)];
6 Comments
Walter Roberson
on 1 Aug 2015
For simplicity, I suggest that you use zeros() with the size of the desired output matrix, and then you copy the input matrix to the appropriate location in the output matrix. For example:
strow = 17; stcol = 53;
outmatrix = zeros(256, 256);
outmatrix(strow + (1:size(inputmatrix,1) - 1, stcol + (1:size(inputmatrix,2) - 1) = inputmatrix;
This would put inputmatrix into a 256 x 256 matrix with upper left corner) at outputmatrix(17,53)
I have no present information as to the size of matrix required for the toolbox you are using.
More Answers (0)
See Also
Categories
Find more on Data Type Identification 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!