Error using vertcat Dimensions of arrays being concatenated are not consistent.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Torsten
il 24 Mag 2021
Modificato: Torsten
il 24 Mag 2021
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).
Risposta accettata
G A
il 24 Mag 2021
Modificato: G A
il 24 Mag 2021
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!