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
2020년 8월 30일
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!