using meshgrid data in a matrix

3 visualizaciones (últimos 30 días)
mohammad mortezaie
mohammad mortezaie el 29 de Mayo de 2020
Comentada: mohammad mortezaie el 29 de Mayo de 2020
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 comentarios
KSSV
KSSV el 29 de Mayo de 2020
All the values are not given...show us the complete code.
mohammad mortezaie
mohammad mortezaie el 29 de Mayo de 2020
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)

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 29 de Mayo de 2020
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 comentarios
KSSV
KSSV el 29 de Mayo de 2020
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 el 29 de Mayo de 2020
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by