Effacer les filtres
Effacer les filtres

Combining 2 matrix of different row numbers but same column numbers.

7 vues (au cours des 30 derniers jours)
Gratitude Kim
Gratitude Kim le 27 Juil 2017
Commenté : Gratitude Kim le 27 Juil 2017
A = [1 0 0 0 1 0 0 0; 0 1 0 0 0 1 0 0; 0 0 1 0 0 0 1 0; 0 0 0 1 0 0 0 1]
B = [1 1 0 0 0 0 0 0 -2 0 0; 0 1 1 0 0 0 0 0 0 -2 0; 0 0 1 1 0 0 0 0 0 0 -2]
ATotal = [A zeros(4,3)]
Afinal = [ATotal B]
I am having this error. Error using horzcat Dimensions of matrices being concatenated are not consistent.
Error in july6 (line 5) Afinal=[ATotal B]
Appreciate your kind assistance.
  1 commentaire
Jan
Jan le 27 Juil 2017
I've formatted your code to make it readable. Please use the "{} Code" button by your own in the future.

Connectez-vous pour commenter.

Réponses (2)

Jan
Jan le 27 Juil 2017
Modifié(e) : Jan le 27 Juil 2017
How coud we help you? You try to concatenate a [4 x 11] and a [3 x 11] matrix horizontally. But the horizontal concatenation requires the same number of rows.
Perhaps you mean the vertical concatenation:
Afinal = [ATotal; B]
But I cannot guess the intention of the code based on the failing code only.
  1 commentaire
Gratitude Kim
Gratitude Kim le 27 Juil 2017
yaya. I know my mistake. I forgot to place a ; thanks anyway.

Connectez-vous pour commenter.


KL
KL le 27 Juil 2017
Dimensions of ATotal and B are not consistent, look at the number of rows.
Afinal=[ATotal [B; zeros(1,size(B,2))]]

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by