Dimensions of arrays being concatenated are not consistent

4 次查看(过去 30 天)
Hi community, i am doing a task, of extracting color features and gobar features, after extracting these features, i am trying to cancate them but it gives error message
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in practice_code (line 19)
Fused_Features = [Extracted_Color_Features, Extracted_Gabor_Features];
i am trying to use vertcat and horzcat function for cancatenating these two features the reason of using these two function is because color features obtained in horizontal position, and gobar features are obtained in vertical features. but still same error are shown. the dimension of color features are 4478x1 and gobar features are 24000x1
so what can i do?

采纳的回答

Walter Roberson
Walter Roberson 2020-2-12
Fused_Features = [Extracted_Color_Features; Extracted_Gabor_Features];
  2 个评论
Awais Khan
Awais Khan 2020-2-12
can you explain what is the purpose of ; because i am using same code but instead of ; i am using , as a result it given an error.
Walter Roberson
Walter Roberson 2020-2-12
vertcat is equivalent to using square brackets for vertically concatenating arrays. For example, [A; B] is equal to vertcat(A,B) when A and B are compatible arrays.
horzcat is equivalent to using square brackets for horizontally concatenating arrays. For example, [A,B] or [A B] is equal to horzcat(A,B) when A and B are compatible arrays.
Phrasing that another way:
  • When you write [A, B] or [A B], what really gets called is horzcat(A,B) -- writing [] is "syntactic sugar", something to make programming easier but which is internally translated to something else.
  • When you write [A;B], what really gets called is vertcat(A,B) -- more syntactic sugar
Also, when you code
[A
B]
what really gets called is vertcat(A,B). And
[A B
C D]
would internally be translated to
vertcat(horzcat(A, B), horzcat(C, D))
If you happened to have
[A B
C]
then you should suspect that there is an error, but it is not necessarily an error. The important part is not the number of expressions: it is whether the expressions expand to compatible sizes. It is, for example, completely valid to have
[1 2 3 4
zeros(1,4)]
which internally would be
vertcat( horzcat(1,2,3,4), zeros(1,4) )

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by