disp error: Dimensions of matrices being concatenated are not consistent.

1 view (last 30 days)
Q_output =
1.0e+03 *
0.0181 0.0011 0.0125
1.1500 0.4000 0.2000
0.0119 -0.0011 0.0175
-0.4000 -0.2000 -0.8000
M=1:3;
I want to display the two matrices above in a table so M is a column before Q_output. I tried disp([M',Q_output]), but I get the following error message
"Error using horzcat
Dimensions of matrices being concatenated are not consistent."
How do I fix it?
Q_output =
1.0e+03 *
0.0181 0.0011 0.0125
1.1500 0.4000 0.2000
0.0119 -0.0011 0.0175
-0.4000 -0.2000 -0.8000
M=1:3;
I want to display the two matrices above in a table so M is a column before Q_output. I tried disp([M',Q_output]), but I get the following error message
"Error using horzcat
Dimensions of matrices being concatenated are not consistent."
How do I fix it?

Answers (1)

Star Strider
Star Strider on 8 Apr 2017
You can’t.
You can have ‘M’ as a row above ‘Q_output’, but since the lengths of ‘M’ and the row length of ‘Q_output’ are not equal, you cannot concatenate them horizontally.
This is the best you can do:
Result = [M; Q_output]

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!