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 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2015-7-31
x = [zeros(floor(ls/2),n); x; zeros(ceil(ls/2),n)];
  6 个评论
Walter Roberson
Walter Roberson 2015-8-1
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by