What this error 'Dimensions of arrays being concatenated are not consistent' means?

67 ビュー (過去 30 日間)
Nisar Ahmed
Nisar Ahmed 2021 年 6 月 13 日
コメント済み: SALAH ALRABEEI 2021 年 6 月 13 日
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in Make_forward_model (line 85)
Vpar = [Vpar.'; 0];
Does it Vpar = [Vpar.'; 0]; to take the transpose?
  2 件のコメント
SALAH ALRABEEI
SALAH ALRABEEI 2021 年 6 月 13 日
If the dimension of Vpar is >1, you cannot concate it with 0. If it is just one array, you can try this instead.
%
Vpar(end+1) = 0;

サインインしてコメントする。

採用された回答

Abhinav Gupta
Abhinav Gupta 2021 年 6 月 13 日
編集済み: Abhinav Gupta 2021 年 6 月 13 日
This type of error is encountered when we try to vertically concatenate arrays that do not have compatible sizes. As an example, lets say we have 2 matrices A and B. To vertically concatenate them, they must have equal number of columns
>> A = ones(2,3);
>> B = zeros(4,3);
>> C = [A;B]
C =
1 1 1
1 1 1
0 0 0
0 0 0
0 0 0
0 0 0
And if we mismatch the number of columns in A and B, and concatenate them, we get this error.
>> B = zeros(2,2)
B =
0 0
0 0
>> C = [A;B]
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
For more information, you could refer to this documentation page:
Hope this helps.

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 6 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by