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!
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!