The problem is:
Product of known dimensions, 3, not divisible into total number of elements, 16.
this because i want to reshape
a
You can also pre-allocate a vector of zeroes, fill in your data for as many elements as there are in your vector, then reshape it when you're done:
vec = 1:16; %// Example data
numRows = 6;
numCols = 3;
newVec = zeros(1:numRows*numCols);
newVec(1:numel(vec)) = vec;
newMat = reshape(newVec, numRows, numCols);