calculate a double integral in a function
1 次查看(过去 30 天)
显示 更早的评论
I want to calculate this double integral in a function that the inputs are m,n and a two variable function like f(x,y) but I don't know how to pass f(x,y) to function.here is my code![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1217012/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1217012/image.jpeg)
clear;clc;close all;
f = @(x,y) sin(2*x)*sin(y);
Bmn = findBmn(1,2,f);
%%
function Bmn = findBmn(m,n,f)
a = pi;
fun = @(x,y) f.*sin(n*pi*x/a).*sin(m*pi*y/a);
Bmn = (4/(a^2)).*integral2(fun,0,a,0,a);
end
0 个评论
采纳的回答
David Hill
2022-12-2
f = @(x,y) sin(2*x).*sin(y);
Bmn = findBmn(1,2,f)
function Bmn = findBmn(m,n,f)
a = pi;
fun = @(x,y) f(x,y).*sin(n*pi*x/a).*sin(m*pi*y/a);
Bmn = (4/(a^2)).*integral2(fun,0,a,0,a);
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Other Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!