How can I define one variable of a 4-variable function, then compute the 3-dimensional integral?
이전 댓글 표시
I have a probability function that has four variables: (charge, x, y, z). I need to use this function for several atoms. I have tried to declare the charge, then integrate with integral3 for x,y, and z, but it hasn't worked.
Here is part of my code:
function h = int3d(a,x,y,z)
h = integral3(func,-x,x,-y,y,-z,z);
%attempting to convert a 4-var function into a 3-var function
function f = func(x1,x2,x3)
f = p(a,x1,x2,x3); %p accepts (charge, x1,x2,x3) and returns numeric answer
end
end
Does anybody have any suggestions? My project depends on being able to perform these integrals. I have searched online and tried for several hours to find a solution, but nothing has worked.
답변 (1개)
Andrei Bobrov
2013년 5월 13일
편집: Andrei Bobrov
2013년 5월 13일
try:
h = integral3(@(x1,y1,z1)p(a,x1,x2,x3),-x,x,-y,y,-z,z);
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!