double summation in matlab

조회 수: 2 (최근 30일)
Samuel Suakye
Samuel Suakye 2020년 4월 21일
편집: darova 2020년 4월 21일
Plotting j_z/j_o against beta_1 = {0,...,10}; and beta_2 = 1, This is what I have done (check the code below) using symsum but for days now it is still running and want to find out whether there are different methods to that. Thanks in advance ;
clc;
b = 0.142e-9; gammao = 3.0; m = 101;
hbar = 1; e = -1;
K = 8.617e-16; T = 287.5;
a = ((3*b)/(2*hbar)); Pz = ((2*pi*hbar)/(3*b));
beta2 = 1; beta1 = linspace(0,10, 30); % However many you want.
Wcnzz = sqrt(3);
jo = ((8*e*Wcnzz*gammao)/(3*hbar*m*b));
%%
syms q s
B1 = q.*beta1; B2 = q.*beta2; v = ((pi.*s)./m); h = (a.*Pz);
z = (2.*(pi.^2).*s.*sqrt(3).*(a./(2*pi)));
Eqszz = (a./(2*pi)).*((1+(4.*cos(h).*cos(v))+(4.*((cos(v)).^2))).^0.5);
Fqszz = ((a.^2).*m)./((z.*((1+(4.*cos(h).*cos(v))+(4.*((cos(v)).^2))).^0.5))./(K.*T));
J1 = besselj(0,B1); J2 = besselj(0,B2);
J = q.*Fqszz.*Eqszz.*J1.*J2;
X = symsum(J,s,1,m);
jz = symsum(X,q,1,inf);
j = jz./jo;
fplot(beta1, j, 'r-', 'LineWidth', 2 );
drawnow;
grid on;
fontSize = 20;
xlabel('\beta_1', 'FontSize', fontSize)
ylabel('j_z/j_o', 'FontSize', fontSize)
hold on
%%
b = 0.142e-9; gammao = 3.0; m = 101;
hbar = 1; e = -1;
K = 8.617e-16; T = 287.5;
a = ((3*b)/(2*hbar)); Pz = ((2*pi*hbar)/(3*b));
beta2 = 1; beta1 = linspace(0,10, 30); % However many you want.
Wcnac = 1; t = sqrt(3); n = 1e-9;
jo = ((8*e*Wcnac*gammao)/(3*hbar*m*b));
%%
syms q s
B1 = q.*beta1; B2 = q.*beta2; u = ((a.*Pz)./t); g = ((pi.*s.*t)./n);
y = (2.*(pi.^2).*s.*t);
Eqsac = ((1+(4.*cos(g).*cos(u))+(4.*((cos(u)).^2))).^0.5);
Fqsac = ((a.^2).*n)./((y.*((1+(4.*cos(g).*cos(u))+(4.*((cos(u)).^2))).^0.5))./(K.*T));
J1 = besselj(0,B1); J2 = besselj(0,B2);
J = q.*Fqsac.*Eqsac.*J1.*J2;
X1 = symsum(J,s,1,m);
jz = symsum(X1,q,1,inf);
j = jz./jo;
fplot(beta1, j, 'b-', 'LineWidth', 2);
drawnow;
grid on;
fontSize = 20;
xlabel('\beta_1', 'FontSize', fontSize)
ylabel('j_z/j_o', 'FontSize', fontSize)
title('j_x/j_o vs. \beta_1', 'FontSize', fontSize)
legend('zigzig CNs','armchair CNs','Location','Best');
% Maximize the figure window.
hFig.WindowState = 'maximized';
  댓글 수: 3
Samuel Suakye
Samuel Suakye 2020년 4월 21일
편집: Samuel Suakye 2020년 4월 21일
not a mistake.
darova
darova 2020년 4월 21일
It's strangle because it can be simplified

댓글을 달려면 로그인하십시오.

답변 (1개)

darova
darova 2020년 4월 21일
Here is numerical approach
clc,clear
% alignComments
b = 0.142e-9;
gammao = 3.0;
m = 101;
hbar = 1;
e = -1;
K = 8.617e-16;
T = 287.5;
a = 3*b/(2*hbar);
Pz = 2*pi*hbar/(3*b);
beta2 = 1;
beta1 = linspace(0,10, 100); % However many you want.
Wcnzz = sqrt(3);
jo = 8*e*Wcnzz*gammao/(3*hbar*m*b);
[q,s] = meshgrid(1:0.1:3,1:m); % 1:0.1:3 span for 'q'
cps = cos(pi.*s./m);
cap = cos(a.*Pz);
Eqszz = a/2/pi*sqrt(1 + 4*cap.*cps + 4*cps.^2);
Fqszz = a^2*m*K*T ./ (2*pi^2*s.*sqrt(3).*Eqszz);
for i = 1:length(beta1)
B1 = q.*beta1(i);
B2 = q.*beta2;
J1 = besselj(0,q.*B1);
J2 = besselj(0,q.*B2);
tmp = q.*Fqszz.*Eqszz.*J1.*J2;
J(i) = sum(tmp(:));
end
plot(beta1,J)
I don't know if q value can be float number but the result looks nices
  댓글 수: 1
Samuel Suakye
Samuel Suakye 2020년 4월 21일
편집: darova 2020년 4월 21일
q is to infinity, and the float number depends
but am expecting something like the graph below

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by