MATLAB: Error vertcat not using vertcat

MATLABvertcat

Hello, i´ve used the following line and get the vertcat error
Kx = [407 -169 0 0 0 0 0 0 0 0;-169 331 -162 0 0 0 0 0 0 0; -162 320 -158 0 0 0 0 0 0;0 0 -158 311 -153 0 0 0 0 0;0 0 0 -153 301 -148 0 0 0 0;0 0 0 0 -148 293 -145 0 0 0;0 0 0 0 0 -145 279 -134 0 0;0 0 0 0 0 0 -134 249 -115 0;0 0 0 0 0 0 0 -115 222 -107;0 0 0 0 0 0 0 0 -107 107]
I can´t understand where is the problem since i created the line in excel and it worked perfect for the following line
M=[12.5280326197757 0 0 0 0 0 0 0 0 0;0 12.5280326197757 0 0 0 0 0 0 0 0;0 0 12.5280326197757 0 0 0 0 0 0 0;0 0 0 12.5280326197757 0 0 0 0 0 0;0 0 0 0 12.5280326197757 0 0 0 0 0;0 0 0 0 0 12.5280326197757 0 0 0 0;0 0 0 0 0 0 12.5280326197757 0 0 0;0 0 0 0 0 0 0 12.5280326197757 0 0;0 0 0 0 0 0 0 0 12.5280326197757 0;0 0 0 0 0 0 0 0 0 10.519877675841]
How can i solved it?

Best Answer

Your matrix is 10*10
Kx = [407 -169 0 0 0 0 0 0 0 0;
-169 331 -162 0 0 0 0 0 0 0;
-162 320 -158 0 0 0 0 0 0; % <-------here there are nine elements
0 0 -158 311 -153 0 0 0 0 0;
0 0 0 -153 301 -148 0 0 0 0;
0 0 0 0 -148 293 -145 0 0 0;
0 0 0 0 0 -145 279 -134 0 0;
0 0 0 0 0 0 -134 249 -115 0;
0 0 0 0 0 0 0 -115 222 -107;
0 0 0 0 0 0 0 0 -107 107]
You have to add an extra zero in 3rd row
Kx = [407 -169 0 0 0 0 0 0 0 0;
-169 331 -162 0 0 0 0 0 0 0;
-162 320 -158 0 0 0 0 0 0 0; % <---- zero added
0 0 -158 311 -153 0 0 0 0 0;
0 0 0 -153 301 -148 0 0 0 0;
0 0 0 0 -148 293 -145 0 0 0;
0 0 0 0 0 -145 279 -134 0 0;
0 0 0 0 0 0 -134 249 -115 0;
0 0 0 0 0 0 0 -115 222 -107;
0 0 0 0 0 0 0 0 -107 107]
Your M matrix was 10*10, all the elements were correct, so it worked. It will work in MATLAB too.