MATLAB: Please help me how to deal with this. i double check this but the same error occurred “Error using vertcat Dimensions of matrices being concatenated are not consistent.”

vercat

M=diag([m10 m9 m8 m7 m6 m5 m4 m3 m2 m1]);
C1=[k10 -k10 0 0 0 0 0 0 0 0];
C2=[-k10 (k10+k9) -k9 0 0 0 0 0 0 0];
C3=[0 -k9 (k9+k8) -k8 0 0 0 0 0 0 ];
C4=[0 0 -k8 (k8+k7) -k7 0 0 0 0 0];
C5=[0 0 0 -k7 (k7+k6) -k6 0 0 0 0] ;
C6=[0 0 0 0 -k6 (k6 +k5) -k5 0 0 0] ;
C7=[0 0 0 0 0 -k5 (k5+k4) -k4 0 0] ;
C8=[0 0 0 0 0 0-k4 (k4 +k3) -k3 0] ;
C9=[0 0 0 0 0 0 0 -k3 (k3+k2) -k2 ];
C10=[0 0 0 0 0 0 0 0 -k2 (k2+k1)];
K=[C1; C2; C3; C4 C5; C6; C7; C8; C9; C10];
n=10; %number of freedom degrees
[V,D]=eig(K,M); % V = eigenvectors

Best Answer

The ‘C8’ vector has 9 columns because ‘0-k4’ is assumed to be a single element. Spaces (and other delimiters) are important in vectors.
C8=[0 0 0 0 0 0-k4 (k4 +k3) -k3 0];
↑ ← PUT A SPACE HERE
C8=[0 0 0 0 0 0 -k4 (k4 +k3) -k3 0];
That will work.