MATLAB: Using meshgrid data in a matrix

meshgrid

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)

Best Answer

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) ;