using meshgrid data in a matrix

조회 수: 4 (최근 30일)
mohammad mortezaie
mohammad mortezaie 2020년 5월 29일
댓글: mohammad mortezaie 2020년 5월 29일
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
KSSV 2020년 5월 29일
All the values are not given...show us the complete code.
mohammad mortezaie
mohammad mortezaie 2020년 5월 29일
this is complete code
iform=complex(0.0,1.0);
t1=-1.22;
t2=3.665;
t3=-0.205;
t4=-0.105;
t5=-0.055;
alpha1x=0.4460;
alpha2x=0.0992;
alpha3x=0.7505;
alpha4x=0.3976;
alpha5x=0.7530;
alpha1y=0.5571;
alpha2y=0.0;
alpha3y=0.2461;
alpha4y=0.2280;
alpha5y=0.0;
alpha1z=0.0;
alpha2z=0.9052;
alpha3z=0.0;
alpha4z=0.3722;
alpha5z=0.2538;
b=3.37;
a1x=1.41763;
a2x=0.79732;
a3x=a1x+2*a2x;
a4x=a1x+a2x;
a5x=2*a1x+a2x;
a=2*(a1x+a2x);
k_x=0;
k_y=0;
epsilon_x=0;
epsilon_y=0;
epsilon_z=0;
t1_tilda=t1*(1-2*(alpha1x*epsilon_x+alpha1y*epsilon_y+alpha1z*epsilon_z));
t2_tilda=t2*(1-2*(alpha2x*epsilon_x+alpha2y*epsilon_y+alpha2z*epsilon_z));
t3_tilda=t3*(1-2*(alpha3x*epsilon_x+alpha3y*epsilon_y+alpha3z*epsilon_z));
t4_tilda=t4*(1-2*(alpha4x*epsilon_x+alpha4y*epsilon_y+alpha4z*epsilon_z));
t5_tilda=t5*(1-2*(alpha5x*epsilon_x+alpha5y*epsilon_y+alpha5z*epsilon_z));
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);
[m,n] = size(f_k) ;
eps1 = linspace(0,2,n) ;
eps2 = linspace(0,2,m) ;
[e1,e2] = meshgrid(eps1,eps2) ;
H=[f_k+e1 g_k;conj(g_k) f_k+e2];
E=eig(H);
landa1=E(1);
landa2=E(2);
EG=landa2-landa1;
contour(e1,e2,EG,100)

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
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
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?
mohammad mortezaie
mohammad mortezaie 2020년 5월 29일
My problem exactly is using meshgrid data's e1 and e2 in H matrix. I tried this code without puting e1 and e2 in matrix and code runes without error. So only question here is that how can i use this meshgrids in a matrix and dont face with error.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by