Error vertcat not using vertcat

2 vues (au cours des 30 derniers jours)
Bruno Gonzalo Reynoso
Bruno Gonzalo Reynoso le 23 Sep 2020
Modifié(e) : KSSV le 23 Sep 2020
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?
  1 commentaire
Stephen23
Stephen23 le 23 Sep 2020
Putting all of the data onto one line makes it difficult to debug. If you simply arrange the matrix line-by-line, it is quite obvious that the 3rd row is shorter than all of the other rows:
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; % <- shorter!
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
To avoid similar errors you should also use delimiting commas rather than spaces.

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 23 Sep 2020
Modifié(e) : KSSV le 23 Sep 2020
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.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by