MATLAB Answers

Need Help Error using vertcat Dimensions of arrays being concatenated are not consistent. Error in myModel (line 20) dy = [lambda+th​eta1*Va+th​eta2*Vb-(b​eta*Ih+ mu+ alpha1+alpha2)*S;

1 ビュー (過去 30 日間)
khagendra adhikari
khagendra adhikari 2020 年 3 月 13 日
コメント済み: Jon 2020 年 3 月 17 日
Please Help to resolve it
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in myModel (line 20)
dy = [lambda+theta1*Va+theta2*Vb-(beta*Ih+ mu+ alpha1+alpha2)*S;

  0 件のコメント

サインイン to comment.

採用された回答

Jon
Jon 2020 年 3 月 13 日
編集済み: Jon 2020 年 3 月 13 日
The line of code you provide does not provide enough information to provide specific guidance. First you are missing a right hand square bracket to close the expression, and there is no way of knowing how the dimensions (number of rows and columns) of the variables you list.
However here are some general ideas that hopefully help:
When you combine vectors or arrays into a larger matrix by "concatenating them" then for it to make sense the dimensions must be consistent.
So if for example if I am combining matrices using horizontal concatenation (putting them side by side) each matrix must have the same number of rows.
So this is OK
X = [1 2;3 4] % has 2 rows
Y = [8;9] % has 2 rows
Z = [X Y] % everything has 2 rows
and this isn't
X = [1 2;3 4] % has 2 rows
Y = [8;9;10] % has 3 rows
Z = [X Y] % no good number of rows is not consistent
If I you are combining matrices using vertical concatentation (stacking them on top of each other) they must have the same number of columns.
X = [1 2;3 4] % has 2 columns
Y = [8 9] % has 2 columns
Z = [X; Y] % everything has 2 columns
and this isn't
X = [1 2;3 4] % has 2 columns
Y = [8 9 10] % has 3 columns
Z = [X; Y] % no good number of rows is not consistent
So check the individual elements that you are combining to see what their dimensions (for example look in the workspace tab) are and make sure that they are consistent if you are trying to combine them into a larger matrix.

その他の回答 (0 件)

サインイン してこの質問に回答します。


Translated by