Info

此问题已关闭。 请重新打开它进行编辑或回答。

please help me, i wrote the following code. but all results is NaN and give me empty diagram . where the problem in my code or where is the error ?

1 次查看(过去 30 天)
% [fxxdc]=therioticalfunction(1,0.2)
function [ fxxdc]=therioticalfunction(ld,a)
[w1,w2]=meshgrid(0:pi/20:pi,0:pi/20:pi);
fxxdc=abs((((ld*exp(ld)*(3*ld + exp(2*ld) - 2*exp(ld) - 3*ld*exp(ld) + ld^2 + ld^2*exp(ld) + 1))/(exp(ld) - 1)^3 + (ld*exp(ld)*((exp(-ld) - 1)*a - 2*ld*exp(-ld)*a^2)*(ld - exp(ld) + 1))/((exp(ld) - 1)^2*((1 - exp(-ld))*a^2 + (exp(-ld) - 1)*a)))*((a^3*exp(i*w1)*exp(-i*w2)*(exp(-ld) - 1)^2)/((a*exp(-i*w2)*(exp(-ld) - 1) + 1)*(exp(i*w1)*(exp(-ld) - 1)*a^2 + 1)) + (a^3*exp(i*w2)*exp(-i*w1)*(exp(-ld) - 1)^2)/((a*exp(-i*w1)*(exp(-ld) - 1) + 1)*(exp(i*w2)*(exp(-ld) - 1)*a^2 + 1)) + (a^3*exp(i*(w1 + w2))*exp(i*w1)*(exp(-ld) - 1)^2)/((a*exp(i*(w1 + w2))*(exp(-ld) - 1) + 1)*(exp(i*w1)*(exp(-ld) - 1)*a^2 + 1)) + (a^3*exp(i*(w1 + w2))*exp(i*w2)*(exp(-ld) - 1)^2)/((a*exp(i*(w1 + w2))*(exp(-ld) - 1) + 1)*(exp(i*w2)*(exp(-ld) - 1)*a^2 + 1)) + (a^3*exp(-i*(w1 + w2))*exp(-i*w1)*(exp(-ld) - 1)^2)/((a*exp(-i*w1)*(exp(-ld) - 1) + 1)*(exp(-i*(w1 + w2))*(exp(-ld) - 1)*a^2 + 1)) + (a^3*exp(-i*(w1 + w2))*exp(-i*w2)*(exp(-ld) - 1)^2)/((a*exp(-i*w2)*(exp(-ld) - 1) + 1)*(exp(-i*(w1 + w2))*(exp(-ld) - 1)*a^2 + 1))) - ((ld*exp(ld)*(3*ld + exp(2*ld) - 2*exp(ld) - 3*ld*exp(ld) + ld^2 + ld^2*exp(ld) + 1))/(exp(ld) - 1)^3 + (ld*exp(ld)*((exp(-ld) - 1)*a - 2*ld*exp(-ld)*a^2)*(ld - exp(ld) + 1))/((exp(ld) - 1)^2*((1 - exp(-ld))*a^2 + (exp(-ld) - 1)*a)))*((a^2*exp(-i*(w1 + w2))*(exp(-ld) - 1))/(exp(-i*(w1 + w2))*(exp(-ld) - 1)*a^2 + 1) + (a^2*exp(i*w1)*(exp(-ld) - 1))/(exp(i*w1)*(exp(-ld) - 1)*a^2 + 1) + (a^2*exp(i*w2)*(exp(-ld) - 1))/(exp(i*w2)*(exp(-ld) - 1)*a^2 + 1)) + (ld*exp(ld)*(3*ld + exp(2*ld) - 2*exp(ld) - 3*ld*exp(ld) + ld^2 + ld^2*exp(ld) + 1))/(exp(ld) - 1)^3 - (ld*exp(ld)*((a*exp(i*(w1 + w2))*(exp(-ld) - 1))/(a*exp(i*(w1 + w2))*(exp(-ld) - 1) + 1) + (a*exp(-i*w1)*(exp(-ld) - 1))/(a*exp(-i*w1)*(exp(-ld) - 1) + 1) + (a*exp(-i*w2)*(exp(-ld) - 1))/(a*exp(-i*w2)*(exp(-ld) - 1) + 1))*(3*ld + exp(2*ld) - 2*exp(ld) - 3*ld*exp(ld) + ld^2 + ld^2*exp(ld) + 1))/(exp(ld) - 1)^3 - (ld*exp(ld)*((exp(-ld) - 1)*a - 2*ld*exp(-ld)*a^2)*(ld - exp(ld) + 1)*((a^2*exp(i*(w1 + w2))*exp(i*w1)*(exp(-ld) - 1)^2)/((a*exp(i*(w1 + w2))*(exp(-ld) - 1) + 1)*(a*exp(i*w1)*(exp(-ld) - 1) + 1)) + (a^2*exp(i*(w1 + w2))*exp(i*w2)*(exp(-ld) - 1)^2)/((a*exp(i*(w1 + w2))*(exp(-ld) - 1) + 1)*(a*exp(i*w2)*(exp(-ld) - 1) + 1)) + (a^2*exp(-i*(w1 + w2))*exp(-i*w1)*(exp(-ld) - 1)^2)/((a*exp(-i*(w1 + w2))*(exp(-ld) - 1) + 1)*(a*exp(-i*w1)*(exp(-ld) - 1) + 1)) + (a^2*exp(-i*(w1 + w2))*exp(-i*w2)*(exp(-ld) - 1)^2)/((a*exp(-i*(w1 + w2))*(exp(-ld) - 1) + 1)*(a*exp(-i*w2)*(exp(-ld) - 1) + 1)) + (a^2*exp(i*w1)*exp(-i*w2)*(exp(-ld) - 1)^2)/((a*exp(i*w1)*(exp(-ld) - 1) + 1)*(a*exp(-i*w2)*(exp(-ld) - 1) + 1)) + (a^2*exp(i*w2)*exp(-i*w1)*(exp(-ld) - 1)^2)/((a*exp(i*w2)*(exp(-ld) - 1) + 1)*(a*exp(-i*w1)*(exp(-ld) - 1) + 1))))/((exp(ld) - 1)^2*((1 - exp(-ld))*a^2 + (exp(-ld) - 1)*a)) + (ld*exp(ld)*((exp(-ld) - 1)*a - 2*ld*exp(-ld)*a^2)*((a*exp(-i*(w1 + w2))*(exp(-ld) - 1))/(a*exp(-i*(w1 + w2))*(exp(-ld) - 1) + 1) + (a*exp(i*w1)*(exp(-ld) - 1))/(a*exp(i*w1)*(exp(-ld) - 1) + 1) + (a*exp(i*w2)*(exp(-ld) - 1))/(a*exp(i*w2)*(exp(-ld) - 1) + 1))*(ld - exp(ld) + 1))/((exp(ld) - 1)^2*((1 - exp(-ld))*a^2 + (exp(-ld) - 1)*a)))/(4*pi^2));
mesh(w1,w2,fxxdc)
end
  2 个评论
Rafael Hernandez-Walls
I think your code can improve. You can try changing all multiplications (*) to (. *) And all divisions (/) to (./) and you will see that your code improves. This because you are working with two matrices (w1 and w2).

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by