calculate a double integral in a function

1 回表示 (過去 30 日間)
Niloufar
Niloufar 2022 年 12 月 2 日
回答済み: David Hill 2022 年 12 月 2 日
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
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

採用された回答

David Hill
David Hill 2022 年 12 月 2 日
f = @(x,y) sin(2*x).*sin(y);
Bmn = findBmn(1,2,f)
Bmn = 1.0000
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 件)

カテゴリ

Help Center および File ExchangeParallel Computing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by