Matlab graphs not showing

Below are my codes
n = 5*10e12;
vf = 1.0*10e6;
mo = 9.109*10e-31;
m = 0.44*mo;
tau = 10e-12;
e = 1; %1.6022e-19;
E0 = 10; % Unit in KV/m
s = 3.5*10e3;
hBar = 1; %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);
Wc = ((e.*thisN)./m);
g = 1 + (1i.*Wc.*tau); gstar = 1 - (1i.*Wc.*tau);
BF = repmat(((k.*vf)./Wc),101,1);
for i = 1:length(W)
R = (L.*(besselj(L,BF).^2))./(1-1i.*(W(i)-(L.*Wc)).*tau);
Rx = ((Wc./k).*sum(R(:)));
Sx = ((L.*besselj(L,BF)).^2)./(1-1i.*(W(i)-(L.*Wc)).*tau);
Sxx = ((2*s0)./(BF.^2)).*sum(Sx(:));
gkw = 1+(1i.*(1./(Eo*(Ed+1))).*(Sxx./(s - Rx)));
J = besselj(L,BF)./(1-1i.*(W(i)-(L.*Wc)).*tau).*(L+((k.*a0.*Sxx)./(Wc.*tau)./(Eo.*(s-Rx)))).*((g.*(L+1).*besselj(L+1,BF))+(gstar.*(L-1).*besselj(L-1,BF)));
Jx = jo.*((abs((s0*E0)./gkw)).^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')

 Risposta accettata

maiaL
maiaL il 3 Set 2020

0 voti

Nothing is plotted because Jx is all NaN's, so something is wrong with your calculations.

6 Commenti

I don't know what this script is about, seems to be something with eletric/electromagnetic fields. But upon a quick inspection, the source of the NaN's is from divisions by zero in line 29:
Sxx = ((2*s0)./(BF.^2)).*sum(Sx(:));
The first column of BF are zeros, so you have some divisions by zero there.
Plotting this equation numerically so I used meshgrid
maiaL
maiaL il 3 Set 2020
Can't help you with the math. The plot part of the script looks alright. It's just that what you're trying to plot are NaN's.
Samuel Suakye
Samuel Suakye il 3 Set 2020
Modificato: Samuel Suakye il 3 Set 2020
Is there any way to plot this numerically ... because of the summation?
maiaL
maiaL il 3 Set 2020
I dont understand what you're asking.
I used grid to plot those equations numerically. And am asking whether there is another way to plot same equations using vectors numerically

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by