Clear Filters
Clear Filters

besselj: NU and Z must be the same size or one must be a scalar.

4 views (last 30 days)
Plotting the following equation i.e. jx vs. omega (w) (find below) numerically but say NU and z of the besselj must have same size or one must be scalar
This is what I have done so far
n = 5*10e12;
vf = 1.0*10e6;
mo = 9.109*10e-31;
m = 0.44*mo;
tau = 10e-12;
e = 1.6022e-19;
E0 = 10; % Unit in KV/m
s = 3.5*10e3;
hBar = 6.52*10e-16;
Ed = 50;
Eo = 8.85*10-12;
B = [0.1, 0.2, 0.3]; % Unit in Tesla
W = linspace(0,10, 101); % However many you want.
k = W./s;
a0 = (2*pi*(hBar^2)*Eo)/m/e^2;
s0 = ((e^2)*n*tau)/m;
jo = 1./e/n/vf;
[L] = meshgrid(-10000:200:10000); % 1:0.1:3 span for 'q'
legendStrings = cell(length(B), 1);
for k1 = 1:length(B)
thisN = B(k1);
for i = 1:length(W)
Wc = ((e.*thisN)./m);
g = 1 + (1i.*Wc.*tau); gstar = 1 - (1i.*Wc.*tau);
BF = (k.*vf)./Wc;
R = (L.*(besselj(L,BF).^2))./(1-1i.*(W(i)-(L.*Wc)).*tau);
Rx(i) = (Wc./k).*sum(R(:));
Sx = ((L.*besselj(L,BF)).^2)./(1-1i.*(W(i)-(L.*Wc)).*tau);
Sxx(i) = ((2*s0)./(BF.^2)).*sum(Sx(:));
gkw(i) = 1 + (1i.*(1./Eo(Ed+1)).*(Sxx(i)./(s - Rx(i))));
J = besselj(L,BF)./(1-1i.*(W(i)-(L.*Wc)).*tau).*(L+((k.*a0.*Sxx(i))./(Wc.*tau)./(Eo.*(s-Rx(i))))).*((g.*(L+1).*besselj(L+1,BF))+(gstar.*(L-1).*besselj(L-1,BF)));
Jx(i) = jo.*((abs((s0*E0)./gkw(i))).^2).*(1./(BF.^2)./(1+(Wc.*tau).^2)).*sum(J(:));
end
legendStrings{k1} = sprintf('B = %.3f', thisN);
plot(W, real(Jx), '-', 'LineWidth', 2, 'MarkerSize', 15);
hold on;
drawnow;
end
grid on;
fontSize = 15;
xlabel('\omega (ns^{-1})', 'FontSize', fontSize)
ylabel('\it j_{x} (\mu A/m)', 'FontSize', fontSize)
title('\it j_{x} (\mu A/m) vs. \omega (ns^{-1}) ', 'FontSize', fontSize)
legend(legendStrings, 'Location', 'Best')

Accepted Answer

Walter Roberson
Walter Roberson on 2 Sep 2020
Yes, your calculations are not being careful about whether you are operating on grids or vectors.
You can repmat(BF) to be a grid like L is, but you have more problems.
Your k is at least a vector but you have
Rx(i) = (Wc./k).*sum(R(:));
With k being non-scalar, the right hand side is non-scalar.
Why are you saving to Rx(i), Sxx(i), gkw(i)? You are not using any of those after the loop and you never index at other elements within the loop.
Why are you calculating Wc, g, gstar, BF each time through the for i loop? They do not depend upon the value of i. Nothing depends upon the value of i until the denominator of R .
  13 Comments
Walter Roberson
Walter Roberson on 18 Feb 2021
sap = sin(Q(pi));
Exactly 0.
vx = -(2*a*(t^2)*cps*sap)/Eqs;
Multiplies by the exact 0, so the result is exact 0.
tau = (mu*p)/e/vx;
Divide by 0.
jo = -1./(2*e*n*vx);
Divide by 0.
Jx = jo.*SE.*CC.*DD.*sum((Besselj(Bg,r)./(1-1i.*(W(i)-(r.*Wc)).*tau)).*(r-((k.*bg.*Sxx)./(Wc.*tau)./(Eo.*(s-Rx).*gkw))).*BB.*((-1i.*(g.^2).*(r+1).*Besselj(Bg,r+1))+(1i.*(gstar.^2).*(r-1).*Besselj(Bg,r-1))));
Multiplies by the result of division by 0, so without looking further you can predict that Jx will either be +inf or -inf or NaN. It turns out that it becomes NaN.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!