Error using vertcat Dimensions of arrays being concatenated are not consistent.
4 ビュー (過去 30 日間)
古いコメントを表示
I have copied three matrices generated in Python to Matlab.
Matlab however tells me that for the Y0 matrix:
Error using vertcat Dimensions of arrays being concatenated are not consistent.
Error in Y0Y1Y2 (line 3) Y0=[[0.-20.j , 0. +0.j , 0. +0.j , 0. +0.j ],
If I delete Y0, Y1 and Y2 are fine. There is just something wrong with Y0, but I can't understand what.
Y0=[[0.-20.j , 0. +0.j , 0. +0.j , 0. +0.j ],
[0. +0.j , 0.-12.j , 0. +2.j , 0. +0.j ],
[0. +0.j , 0. +2.j , 0.-12.j , 0. +0.j ],
[0. +0.j , 0. +0.j , 0. +0.j , 0. -2.85714286j]]
Y1=[[0.-12.68115942j, 0. +8.33333333j, 0. +0.j , 0. +0.j ],
[0. +8.33333333j, 0.-15.j , 0. +6.66666667j, 0. +0.j ],
[0. +0.j , 0. +6.66666667j, 0.-15.j , 0. +8.33333333j],
[0. +0.j , 0. +0.j , 0. +8.33333333j, 0.-12.5j ]]
Y2=[[0.-16.02564103j, 0. +8.33333333j, 0. +0.j , 0. +0.j ],
[0. +8.33333333j, 0.-15.j , 0. +6.66666667j, 0. +0.j ],
[0. +0.j , 0. +6.66666667j, 0.-15.j , 0. +8.33333333j],
[0. +0.j , 0. +0.j , 0. +8.33333333j, 0.-15.47619048j]]
4 件のコメント
Torsten
2021 年 5 月 24 日
編集済み: Torsten
2021 年 5 月 24 日
Ok, then do the necessary changes to Y0, Y1 and Y2 I explained in my answer:
Remove the [] around the vectors, replace the , at the end of each line by ; ... and write a+1i*b for the complex numbers instead of a+bj (without spaces, as G A observed).
採用された回答
G A
2021 年 5 月 24 日
編集済み: G A
2021 年 5 月 24 日
It seams that if there is a space between the real and imaginary parts of the number, Matlab considers it as two different numbers. So rewrite your matrices without spaces.
% with spaces
[0.-20.j , 0. +0.j , 0. +0.j , 0. +0.j ]
ans =
Column 1
0 - 20i
Column 2
0 + 0i
Column 3
0 + 0i
Column 4
0 + 0i
Column 5
0 + 0i
Column 6
0 + 0i
Column 7
0 + 0i
% without spaces
[0.-20.j , 0.+0.j , 0.+0.j , 0.+0.j ]
ans =
Column 1
0 - 20i
Column 2
0 + 0i
Column 3
0 + 0i
Column 4
0 + 0i
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!