# How can I put meshgride data in a matrix and calculate eigenvalues and eigenvectors?

2 views (last 30 days)
I have below code for creating a meshgrid of k_x and k_y in order to put them in the 2*2 matrix and calculate eigenvectors and eigenvalues. But i recived the error "Dimensions of arrays being concatenated are not consistent.". How can I fix it?
My code is:
a=1.855;
eb=-3.276;
ep=-1.979;
t0=-1.844;
delta1x=a/2;
delta1y=a*sqrt(3)/2;
delta2x=a/2;
delta2y=-a*sqrt(3)/2;
delta3x=-a;
delta3y=0;
onsite1=ep;
onsite2=eb;
t1=1;
t2=2;
t3=3;
iform=complex(0.0,1.0);
kx=-2:0.05:2;
ky=-2:0.05:2;
[k_x,k_y]=meshgrid(kx,ky);
phi=t1.*exp(iform.*k_x.*delta1x).*exp(iform.*k_y.*delta1y)+t2.*exp(iform.*k_x.*delta2x).*exp(iform.*k_y.*delta2y)+t3.*exp(iform.*k_x.*delta3x);H2=[onsite1 phi;conj(phi) onsite2];
[v,E]=eig(H2);

Walter Roberson on 5 Sep 2021
a=1.855;
eb=-3.276;
ep=-1.979;
t0=-1.844;
delta1x=a/2;
delta1y=a*sqrt(3)/2;
delta2x=a/2;
delta2y=-a*sqrt(3)/2;
delta3x=-a;
delta3y=0;
onsite1=ep;
onsite2=eb;
t1=1;
t2=2;
t3=3;
iform=complex(0.0,1.0);
kx=-2:0.05:2;
ky=-2:0.05:2;
[k_x,k_y]=meshgrid(kx,ky);
phi=t1.*exp(iform.*k_x.*delta1x).*exp(iform.*k_y.*delta1y)+t2.*exp(iform.*k_x.*delta2x).*exp(iform.*k_y.*delta2y)+t3.*exp(iform.*k_x.*delta3x);
H2 = [onsite1*ones(size(phi)) phi; conj(phi) onsite2*ones(size(phi))];
[v,E]=eig(H2);
size(v), size(E)
ans = 1×2
162 162
ans = 1×2
162 162
mohammad mortezaie on 5 Sep 2021
Thank you so much.