MATLAB: Error using vertcat. Dimensions of matrices being concatenated are not consistent.

vertcat

a=[ones(1,c);[ap',a]];
b=eye(c,1);
q=a/b
For this line of code, I got error using vertcat. Is there any solution for this?

Best Answer

The error message is clear. You're vertically concatenating a matrix with c columns, ones(1, c) with a matrix with a different number of columns, [ap', a]. Since the number of columns does not match you get an error.
As we have no idea what you're doing it's difficult to tell you how to solve the problem, other than make sure that c is the number of column in [ap', a], that is c must be equal to size(ap, 1) + size(a, 2) (number of rows in ap since you transpose it + numbers of rows in a).
Related Question