Unable to perform assignment because the left and right sides have a different number of elements.

1 次查看(过去 30 天)
there is this error ''Unable to perform assignment because the left and right sides have a different number of elements'' pooping up in my code and need help...thank you
clc; clear; close all;
% PLOTTED IN CGS or SI UNITS
%% Data
qe = 1; %1.6022e-19;
n = 5e16;
E0 = 10*10^3;
m0 = 9.1094e-31;
m = 0.44*m0;
e0 = 1; %8.8542e-12;
ed = 50;
s = 3.5e3;
ue = 1;
eps0 = 1; %8.8542e-12;
h = 4.1356e-15; %6.6261e-34; %
hBar = h/(2*pi());
b = 0.142e-9;
a = 3*b/2/hBar;
tt = 2.6; %*1e-19;
w = 10^12; %(5.7/2); %*1e-19; Bandgap
%% J vs w
figure
linAx = axes('nextplot','add');
col = {'-', '-.', '--'}; %[0,0,1;0.9,0.4,0.17;0,1,0]; % Blue, Orange, Green
%LinSty = ["-", "--", ":"]; % linestyle
delta = 2:0.001:10; %linspace(0,10,100); %
JxL = zeros(size(delta));
i = 0;
for B = 0.1:0.1:0.3
j = 0;
i = i+1;
for Delta = delta
j = j+1;
k = (w/s);
p = 0.525; %-k/2 + (1/a)*asin(hBar*w*G/4/tt^2/sin(k*a/2));
G = sqrt(delta.^2 + 5*tt^2);
v = (-2*tt^2*a*sin(p*a)./G);
t1 = ue*p./(qe.*v);
t2 = t1/2;
wc = qe*B.*v./p;
gamma = 1 + 1i.*wc.*t2;
Sigg = qe^2*n.*v.*t1./p;
Sixx = p^2/(2*pi*hBar^2);
Rixx = 2*p./m./v;
ag = 2*pi*hBar^2*eps0.*v./(qe^2*p);
bF = (k.*v./wc).*1e-9;
Sigxx = 0; Rx = 0;
for l = -3:3
Sigxx = Sigxx + (l*besselj(l,bF)).^2./(1 - 1i*(w-l.*wc).*t1);
Rx = Rx + l*besselj(l,bF).^2/(1 - 1i*(w-l.*wc).*t1);
end
Sigxx = 2*Sixx.*Sigg.*Sigxx./bF.^2;
Rx = Rixx.*wc.*Rx./k;
g = 1 + 1i.*Sigxx./(e0*(ed+1)*(s-Rx));
SxL = 0;
for l = 0:0
SxL = SxL + (besselj(l,bF)./(1-1i.*(w-l.*wc).*t1)).*(l + k.*ag.*Sigxx./(wc.*t1.*eps0.*(s-Rx))).*...
(-1i.*gamma.^2.*(l+1).*besselj(l+1,bF) + 1i.*conj(gamma).^2.*(l-1).*besselj(l-1,bF));
end
C = (1./(2*qe*n.*v)).*abs(Sigg*E0./g).^2.*(((1./bF)./(1 + wc.^2.*t2.^2)).^2);
A = t1.*wc.*p^2./2./pi./hBar;
JxL(j) = C.*A.*real(SxL);
end
plot(linAx,delta,JxL, col{i})
end
Unable to perform assignment because the left and right sides have a different number of elements.
fontSize = 12;
set(groot,'defaultLineLineWidth',1.3)
xlabel(linAx,'\omega_{\it q} (ns^{-1})', 'FontSize', fontSize)
ylabel(linAx,'\it j_{x} (p A/m)', 'FontSize', fontSize)
% title(linAx,'Graphene with an Energy Bandgap') %Linear Dispersion Case
legend(linAx,'B = 0.1 T','B = 0.2 T', 'B = 0.3 T','Location','Best')
%axis auto([-5e-9 25e-9 0e8 2e8 10e8])
set(gca, 'fontsize', 12, 'linewidth', 1.2)
%grid on

采纳的回答

Bora Eryilmaz
Bora Eryilmaz 2022-12-7
编辑:Bora Eryilmaz 2022-12-7
On this line
JxL(j) = C.*A.*real(SxL);
you are trying to assign a vector (C.*A.*...) into a scalar element of the variable JxL(j).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by