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

2 次查看(过去 30 天)
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?

回答(1 个)

Star Strider
Star Strider 2017-4-8
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]

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by