Dimensions of matrices being concatenated are not consistent.

1 次查看(过去 30 天)
Hello, how to fix it: Error using horzcat , Dimensions of matrices being concatenated are not consistent.
x1=[5.55;4.64;3.97;3.51;3.16];
x2=[57.38;39.52;29.33;22.93;18.62];
x3=[0.4;0.5;0.6;0.7;0.8];
Y=[2.01;2.42;2.81;3.16;3.53];
x=[1;1;1;1;1;1];
X=[x x1 x2 x3 x1.*x2 x1.*x3 x2.*x3 x1.^2 x2.^2 x3.^2];
C=X' ;
D=inv(C*X)
E=C*Y;
F = D*E
  2 个评论
Rik
Rik 2019-5-1
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.
Povilas Guras
Povilas Guras 2019-5-1
x1=[5.55;4.64;3.97;3.51;3.16];
x2=[57.38;39.52;29.33;22.93;18.62];
x3=[0.4;0.5;0.6;0.7;0.8];
Y=[2.01;2.42;2.81;3.16;3.53];
x=[1;1;1;1;1;1;1;1;1;1];
X=[x x1 x2 x3 x1.*x2 x1.*x3 x2.*x3 x1.^2 x2.^2 x3.^2];
C=X' ;
D=inv(C*X)
E=C*Y;
F = D*E

请先登录,再进行评论。

采纳的回答

Rik
Rik 2019-5-1
Your x vector is 6x1, while all other vectors are 5x1. Removing one element from that vector lets the code run without error:
x1=[5.55;4.64;3.97;3.51;3.16];
x2=[57.38;39.52;29.33;22.93;18.62];
x3=[0.4;0.5;0.6;0.7;0.8];
Y=[2.01;2.42;2.81;3.16;3.53];
x=[1;1;1;1;1];
X=[x x1 x2 x3 x1.*x2 x1.*x3 x2.*x3 x1.^2 x2.^2 x3.^2];
C=X' ;
D=inv(C*X)
E=C*Y;
F = D*E

更多回答(0 个)

类别

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