using meshgrid data in a matrix
4 次查看(过去 30 天)
显示 更早的评论
I tried to use a meshgrid data in a matrix and then evalute eigenvalues. but i faced to "Dimensions of arrays being concatenated are not consistent." error can simeone help me?
my code is:
iform=complex(0.0,1.0);
g_k=2.*t1_tilda.*exp(-iform.*k_x.*a1x).*cos(k_y.*b/2)+t2_tilda.*exp(iform.*k_x.*a2x)+2.*t3_tilda.*exp(iform.*k_x.*a3x).*cos(k_y.*b/2)+t5_tilda.*exp(-iform.*k_x.*a5x);
f_k=4.*t4_tilda.*cos(k_x.*a/2).*cos(k_y.*b/2);
eps1=0:0.01:2;
eps2=0:0.01:2;
[e1,e2]=meshgrid(eps1,eps2);
H=[f_k+e1 g_k;conj(g_k) f_k+e1];
E=eig(H);
landa2=E(1);
landa1=E(2);
EG=landa2-landa1;
contour(e1,e2,EG,10000)
2 个评论
采纳的回答
KSSV
2020-5-29
YOu should modify these lines:
eps1=0:0.01:2;
eps2=0:0.01:2;
[e1,e2]=meshgrid(eps1,eps2);
I hope that g_k, f_k are of same dimensions.
[m,n] = size(f_k) ;
eps1 = linspace(0,2,n) ;
eps2 = linspace(0,2,m) ;
[e1,e2] = meshgrid(eps1,eps2) ;
3 个评论
KSSV
2020-5-29
EG are Eigen values..it will be an array. You cannot use it to plot contour lines. To plot contour lines EG should be a matrix. You can try using diag(EG). But what exactly you want?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!