MATLAB Answers


adding a padding to matrix.

Asked by Portgas Ace on 30 Sep 2012
for example, i have a vector A = [ which has 43 elements ]
if i use reshape (A,9,5)
there is an error since i lack 2 elements to make a 5x9 table. how do i add empty elements to the matrix?

  1 Comment

so there is a value of a matrix which will only be a space.

Sign in to comment.


1 Answer

Matt J
Answer by Matt J
on 30 Sep 2012
Edited by Matt J
on 30 Sep 2012

You haven't specified where the padding should go (beginning/end) and with what values, but this should give you the idea:
A(45)=0; %pad the vector with zeros
B=reshape (A,9,5)


could i possibly do
A(45)= ' ' %pad with only a blank
also, is there any other way to put the paddings on random places.
Matt J
on 30 Sep 2012
With cell arrays, you can do something like that,
A{45}=[]; %pad with empty
As for "padding in random places", you can do things like this:

Sign in to comment.