Dimensions of matrices being concatenated are not consistent.
1 view (last 30 days)
Show older comments
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 Comments
Rik
on 1 May 2019
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.
Accepted Answer
Rik
on 1 May 2019
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 Comments
More Answers (0)
See Also
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!