MATLAB: Dimensions of matrices being concatenated are not consistent

dimensions concatenated

Hello. I have a series of output A=2, B=3, C=4,D=5, E=[1;0.1;0.9]. I'm trying to put all of these output together as a row matrix, F. i.e F = [A B C D E]. But i keep getting the error 'Dimensions of matrices being concatenated are not consistent'. Is there a solution to this please?

Best Answer

Because E is a column vector, not a row vector like you're building with all the rest of the numbers, you must transpose E:
A=2
B=3
C=4
D=5
E=[1; 0.1; 0.9]
F = [A, B, C, D, E']
so now F is a row vector. Or else use semicolons and don't transpose E:
A=2
B=3
C=4
D=5
E=[1; 0.1; 0.9]
F = [A; B; C; D; E]
so now F is a column vector.