Get the same value when using Integral2 function

1 次查看(过去 30 天)
I am using integral2 function to calculate the double integral. The source code is shown as follows:
%% Calculate the drag power for the bare fuselage
bl_bare = @(u,z) Oper.rho .* (u ./ Oper.Vinf) .* 0.5 .* (Oper.Vinf^2 - (u.^2));
ke_out_bare = @(u,z) Oper.rho .* (u ./ Oper.Vinf) .* 0.5 .* ((u - Oper.Vinf).^2);
% Perform double integral
q1_bare = integral2(bl_bare, 0, delta99, 0, 2*pi);
q2_bare = integral2(ke_out_bare, 0, delta99, 0, 2*pi);
D_bare = q1_bare + q2_bare;
%% Calculate the drag power for the bare fuselage with induced velocity field
v_induced = u .* (1 + a_fit);
v_slipstream = u .* (1 + (2 .* a_fit));
bl_induced = @(v_induced,z) Oper.rho .* (v_induced ./ Oper.Vinf) .* 0.5 .* (Oper.Vinf^2 - (v_induced .^2));
ke_out_induced = @(v_slipstream,z) Oper.rho .* (v_slipstream ./ Oper.Vinf) .* 0.5 .* ((v_slipstream - Oper.Vinf).^2);
% Perform double integral
q1_induced = integral2(bl_induced, 0, delta99, 0, 2*pi);
q2_induced = integral2(ke_out_induced, 0, delta99, 0, 2*pi);
D_induced = q1_induced + q2_induced;
However, q1_bare and q1_induced are the same, and q2_bare and q2_induced are the same as well.
I have checked that v_induced and v_slipstream are different from u. However, I cannot figure out why I got the same value.
u and a_fit are 1x30 double, and Oper.Vinf and Oper.rho are 1x1 double.
I appricate all the help. Thank you!

采纳的回答

Torsten
Torsten 2023-8-5
编辑:Torsten 2023-8-6
As I already tried to explain, v_induced and v_slipstream are only formal parameters for the integral2 function. They cannot transport values that you gave to them in a preceding calculation.
The functions bl_induced and q2_induced are called from integral2 with certain values for v_induced and z resp. ke_out_induced and z in the intervals [0,delta99] and [0,2*pi] to approximate the integrals. Thus you get the same result as in the first part of the code ; only the names of the independent variables in your integral functions have changed, but this doesn't influence the values of the integrals.
Maybe you have a matrix of values for bl_induced and ke_out_induced over a 2d-grid for v_induced and z resp. v_slipstream and z. If this is the case, use trapz twice instead of integral2 and take a look at the example "Multiple Numerical Integrations" under
But before, you will have to explain the z-dependency of your functions to be integrated. If they don't depend on z, you have a 1d-integration and you can multiply the result by 2*pi.
  1 个评论
Yi-Kai Peng
Yi-Kai Peng 2023-8-8
Hello Torsten,
Thank you! I used trapz function and it works well. Indeed, the function does not depend on z, so I just multiply the result by 2*pi in the end.

请先登录,再进行评论。

更多回答(0 个)

类别

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