Why does integral2 function changes the array size of variable over which integration is performed?

6 次查看(过去 30 天)
I am using the following command to integrate the function 'fun' with respect to s and t.
X = integral2(fun,0,s_max, 0, t_max, 'method','iterated');
While integrating the size of s and t is taken as 45x1 but sometimes it becomes 30x1. Why the size of integrating variables changes? Whenever the size becomes 30x1 the result of integration is very large abnormal value of power 10^90.

采纳的回答

Mike Hosea
Mike Hosea 2015-4-14
The iterated mode uses adaptive quadrature in each dimension, though your integrand function will, in a sense, be aware of only the inner integral. The length of the array is a function of the number of subintervals needing refinement, and in typical problems varies. With iterated integration it may not vary much if the initial mesh is already fine enough. Your observation that an incorrect result is associated with a certain size is not relevant, except insofar as it may indicate that a mesh refinement was needed. As Roger says, help us out with some more information about your problem, and perhaps we can tell you what the issue really is.

更多回答(1 个)

Roger Stafford
Roger Stafford 2015-4-13
Where you say "While integrating the size of s and t is taken as 45x1 but sometimes it becomes 30x1" , you are apparently referring to the array sizes of s and t which are being sent to your 'fun' integrand function. That is characteristic of many integration routines and the integrand functions must be written so as to properly handle any size array that is sent to them. You can read about this at:
http://www.mathworks.com/help/matlab/ref/integral2.html#inputarg_fun
This has nothing to do with the size of your integration result, which is determined by the integrand function along with the two sets of integration limits. If you obtained 10^90, look at your integrand to see why.
If you want more detailed information, you should show us how your 'fun' and the four integration limits are defined.

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by