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?
0 件のコメント
採用された回答
Walter Roberson
2020 年 2 月 12 日
Fused_Features = [Extracted_Color_Features; Extracted_Gabor_Features];
2 件のコメント
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 Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!