During calculations , a constant is obtained instead of a function
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a complex function that depends on 'd' and 'n' F(n,d) I need to sum a series over 'n' and plot F(d).
I know that after summing by 'n' I should get a function F(d) which is rapidly oscillating and decaying. But after summing, I get a constant that does not depend on d.
My cod:
%% initial conditions
global t k0 h_bar ksi m E;
Ef = 2.77*10^3;
Kb = physconst('boltzmann'); % 1.38*10^(-23)
D = 5:5.1:50;
m = 9.1093837*10^(-31);
Tc = 1.2;
t = 1;
ksi = 10^(-9);
d = D./ksi;
E = Ef/(pi*Kb*Tc);
h_bar = (1.0545726*10^(-34));
k0 = (ksi/h_bar)*sqrt(2.*m.*pi.*Kb.*Tc);
C_2 = 0;
for n = 0:49
C_2 = C_2 + (1/(2.*n+1)).*k0.*real(sqrt(E+1i.*(2.*n+1))-((1+1i)./sqrt(2)).*sqrt(2.*n+1)); % константа
end
%% calculation
F = f_calc(d);
plot(d,F,'o');
%% F(d)
function F = f_calc(d)
global t k0 h_bar ksi m;
F = 0;
for n = 0:49
F = F + 1/(2*n+1).*imag(f_lg(n,t)+1i*d.*k0.*((f_p1(n)-f_p2(n))./2)+1i*f_arg_1(n,d)-1i*f_arg_2(n,d));
end
F = -(1./d).*F;
plot(d,F,'o');
end
function p1 = f_p1(n)
global t;
p1 = ((1+1i)./sqrt(2)).*sqrt(t.*(2.*n+1));
end
function p2 = f_p2(n)
global t E;
p2 = sqrt(E+1i.*t.*(2.*n+1));
end
function n_lg = f_lg(n,d)
global t k0;
arg_of_lg = (1+exp(-1i*d*k0.*f_p1(n)))/(1+exp(-1i*d*k0.*f_p2(n)));
n_lg = log(abs(arg_of_lg));
end
function arg_1 = f_arg_1(n,d)
global t k0;
arg_1 = angle(1+exp(-1i*d*k0.*f_p1(n)));
end
function arg_2 = f_arg_2(n,d)
global t k0;
arg_2 = angle(1+exp(-1i*d*k0.*f_p2(n)));
end
1 comentario
Torsten
el 28 de Dic. de 2022
But after summing, I get a constant that does not depend on d.
You get a vector of values that depends on d. But the difference between its elements is very small compared to their absolute value (1e11).
Respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!