How can I define one variable of a 4-variable function, then compute the 3-dimensional integral?
Show older comments
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.
Answers (1)
Andrei Bobrov
on 13 May 2013
Edited: Andrei Bobrov
on 13 May 2013
try:
h = integral3(@(x1,y1,z1)p(a,x1,x2,x3),-x,x,-y,y,-z,z);
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!