Problems with numerical integration with 2 variables

1 回表示 (過去 30 日間)
Sergio Scalabrino
Sergio Scalabrino 2019 年 3 月 25 日
編集済み: Torsten 2019 年 3 月 27 日
Imagine I have an integral like this:
I can't use integral2!
In this expression, the internal integrals in are not analytical, so they must be done numerically. I can solve the whole equation? I have troubles doing the numerical integrals inside the big integral, because it can't give me an approximated equation in θ. If it was only one integral in theta prime, it would be solvable by "integral2", but it's not the case because there's a product of two ones.
Sergio Scalabrino

採用された回答

Torsten
Torsten 2019 年 3 月 26 日
編集済み: Torsten 2019 年 3 月 26 日
function main
Result = integral(@fun,0,pi/2)
end
function funret = fun(theta)
n = numel(theta);
funret = zeros(n,1);
for idx=1:n
funret(idx) = integral(@(thetastrich)f(theta(idx),thetastrich),0,pi)*...
integral(@(thetastrich)g(theta(idx),thetastrich),0,pi);
end
end
function fret = f(theta,thetastrich)
fret = ...;
end
function gret = g(theta,thetastrich)
gret = ...;
end
  4 件のコメント
Sergio Scalabrino
Sergio Scalabrino 2019 年 3 月 26 日
So in practice you choose a high number of elements in theta (like linspace(0,pi,100)) , and you calculate the integral in of for each of it, having as a result a vector?
And then the vector can be integrated? I thought you can put only function handles
Torsten
Torsten 2019 年 3 月 27 日
編集済み: Torsten 2019 年 3 月 27 日
I don't have to choose any discretization in theta or thetastrich ; "integral" does.
Furthermore, you can use a function instead of a function handle in order to define the function to be integrated .
Your integral can be interpreted as composed of an outer integral in "theta" and an inner function that depends on "theta". This inner function is evaluated for a vector of "theta"- values in "fun". In order to evaluate it, further two calls for given "theta"-values to "integral" are necessary to integrate f and g and form the product of these integrations.
Take in mind that functions "f" and "g" must be able to handle vector input for "thetastrich" and return a vector of the same size as "thetastrich" in "fret" and "gret".

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by