Add a colorbar for this quiver plot
I wrote a code to have a quiver plot as I attached here. I want to add a colorbar to this code as it shows the magnitude of the vectors. How can I do that?
nu1=3.87e5;
nu2=0.46e5;
v_m=2.84e5;
v_p=7.18e5;
%
% nu1=8.4;
% nu2=1;
% v_m=1;
% v_p=2.5;
s=1;
s1=-1;
kesi=1;
kesi1=-1;
DeltaSO=41.9e-3;
alpha=1;
A=0.0;
hbar=1;
V=0;
iform=complex(0.0,1.0);
for i=1:25
k_x=-0.3+2*(i-1)*0.3/25;
for j=1:25
k_y=-0.3+2*(j-1)*0.3/25;
sigmax=[0 1; 1 0];
sigmay=[0 -iform; iform 0];
sigmaz=[1 0; 0 -1];
sigma0=[1 0; 0 1];
H1=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s*kesi)*sigmax+A*(s*sigmaz-kesi*sigmax)+V*sigma0;
H2=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi)*sigmax+A*(s1*sigmaz-kesi*sigmax)+V*sigma0;
H3=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s*kesi1)*sigmax+A*(s*sigmaz-kesi1*sigmax)+V*sigma0;
H4=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi1)*sigmax+A*(s1*sigmaz-kesi1*sigmax)+V*sigma0;
[v1,E1]=eig(H1);
[v2,E2]=eig(H2);
[v3,E3]=eig(H3);
[v4,E4]=eig(H4);
KX(i,j)=k_x;
KY(i,j)=k_y;
sx(i,j)=v4(:,2)’*sigmax*v4(:,2);
sy(i,j)=v4(:,2)’*sigmay*v4(:,2);
end
end
quiver(KX,KY,sx,sy,1)
q.ShowArrowHead = ‘off’;
q.Marker = ‘o’;
QuI wrote a code to have a quiver plot as I attached here. I want to add a colorbar to this code as it shows the magnitude of the vectors. How can I do that?
nu1=3.87e5;
nu2=0.46e5;
v_m=2.84e5;
v_p=7.18e5;
%
% nu1=8.4;
% nu2=1;
% v_m=1;
% v_p=2.5;
s=1;
s1=-1;
kesi=1;
kesi1=-1;
DeltaSO=41.9e-3;
alpha=1;
A=0.0;
hbar=1;
V=0;
iform=complex(0.0,1.0);
for i=1:25
k_x=-0.3+2*(i-1)*0.3/25;
for j=1:25
k_y=-0.3+2*(j-1)*0.3/25;
sigmax=[0 1; 1 0];
sigmay=[0 -iform; iform 0];
sigmaz=[1 0; 0 -1];
sigma0=[1 0; 0 1];
H1=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s*kesi)*sigmax+A*(s*sigmaz-kesi*sigmax)+V*sigma0;
H2=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi)*sigmax+A*(s1*sigmaz-kesi*sigmax)+V*sigma0;
H3=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s*kesi1)*sigmax+A*(s*sigmaz-kesi1*sigmax)+V*sigma0;
H4=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi1)*sigmax+A*(s1*sigmaz-kesi1*sigmax)+V*sigma0;
[v1,E1]=eig(H1);
[v2,E2]=eig(H2);
[v3,E3]=eig(H3);
[v4,E4]=eig(H4);
KX(i,j)=k_x;
KY(i,j)=k_y;
sx(i,j)=v4(:,2)’*sigmax*v4(:,2);
sy(i,j)=v4(:,2)’*sigmay*v4(:,2);
end
end
quiver(KX,KY,sx,sy,1)
q.ShowArrowHead = ‘off’;
q.Marker = ‘o’;
Qu I wrote a code to have a quiver plot as I attached here. I want to add a colorbar to this code as it shows the magnitude of the vectors. How can I do that?
nu1=3.87e5;
nu2=0.46e5;
v_m=2.84e5;
v_p=7.18e5;
%
% nu1=8.4;
% nu2=1;
% v_m=1;
% v_p=2.5;
s=1;
s1=-1;
kesi=1;
kesi1=-1;
DeltaSO=41.9e-3;
alpha=1;
A=0.0;
hbar=1;
V=0;
iform=complex(0.0,1.0);
for i=1:25
k_x=-0.3+2*(i-1)*0.3/25;
for j=1:25
k_y=-0.3+2*(j-1)*0.3/25;
sigmax=[0 1; 1 0];
sigmay=[0 -iform; iform 0];
sigmaz=[1 0; 0 -1];
sigma0=[1 0; 0 1];
H1=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s*kesi)*sigmax+A*(s*sigmaz-kesi*sigmax)+V*sigma0;
H2=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi*v_m*sigma0+kesi*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi)*sigmax+A*(s1*sigmaz-kesi*sigmax)+V*sigma0;
H3=hbar*k_x*nu1*sigmay-hbar*k_y*(s*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s*kesi1)*sigmax+A*(s*sigmaz-kesi1*sigmax)+V*sigma0;
H4=hbar*k_x*nu1*sigmay-hbar*k_y*(s1*nu2*sigmax+kesi1*v_m*sigma0+kesi1*v_p*sigmaz)+DeltaSO*(alpha-s1*kesi1)*sigmax+A*(s1*sigmaz-kesi1*sigmax)+V*sigma0;
[v1,E1]=eig(H1);
[v2,E2]=eig(H2);
[v3,E3]=eig(H3);
[v4,E4]=eig(H4);
KX(i,j)=k_x;
KY(i,j)=k_y;
sx(i,j)=v4(:,2)’*sigmax*v4(:,2);
sy(i,j)=v4(:,2)’*sigmay*v4(:,2);
end
end
quiver(KX,KY,sx,sy,1)
q.ShowArrowHead = ‘off’;
q.Marker = ‘o’;
Qu quiver- colorbar MATLAB Answers — New Questions